@Entity
public class Domain {
@Id
private long id;
/** The parent domain, can be null if this is the root domain. */
@ManyToOne
private Domain parent;
/**
* The children domain of this domain.
*
* This is the inverse side of the parent relation.
*
* <strong>It is the children responsibility to manage there parents children set!</strong>
*/
@OneToMany(mappedBy = "parent")
private Set<Domain> children = new HashSet<Domain>();
I know how to create table like: Create table domain(id int(10),and so on,but I dont understand how to insert Domain parent. And generally i need help in tree application,where need to represent relationsip parent-child