public class Boxes { @Id @GeneratedValue private Long id; @ManyToOne private Boards parentBoard; @ManyToOne private Boxes parentBox; // the root box will have parentBox == null; @OneToMany (cascade = CascadeType.REMOVE) @JoinTable (name = "Boxes_childboxes", joinColumns = @JoinColumn(name="BoxId"), inverseJoinColumns = @JoinColumn(name="childBoxId") ) private Collection childBoxList = new ArrayList(); // the last leaf box will have childBox == null; @OneToMany (cascade = CascadeType.REMOVE) private Collection taskList = new ArrayList(); @Entity public class Tasks { @Id @GeneratedValue private Long id; @ManyToOne private Boxes parentBox; @ManyToMany private Collection taskPrivilegesList = new ArrayList(); @ManyToOne private Companies company; private String title; @Lob private String description; private String priority; // high , low, critical, normal private String status; //completed, working, pending/queued, in problems. @ManyToMany private Collection userList = new ArrayList();