Depending on how you expect to walk the tree, it might not be terribly efficient, however it is doable.
One way would be to have each node store it's parent, that way you only need one table. If you were to do this in annotations it would look like:
Code:
public class AcquirEDModule
{
@Column(length = 255)
private String name;
@Id @GeneratedValue(strategy=GenerationType.AUTO)
private long id;
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade=CascadeType.ALL)
private AcquirEDModule[] children;
@ManyToOne(optional=false, fetch=FetchType.LAZY, cascade={CascadeType.PERSIST, CascadeType.MERGE})
private AcquirEDModule parent;
}
With the table structure of
Code:
table Route (
id bigint not null,
name varchar(255),
parent bigint,
primary key (id)
}