I got it working now, however not sure if I am going overkill with all these annotations!
Also, it looks like I HAVE to use Set<> instead of List<> - bummer!!!
On my parent class I annotate the collection of children as follows:
@OneToMany(mappedBy="parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name="PARENT_ID", nullable=false) @Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN}
On my child class I annotate the bidrectional reference to parent as follows:
@ManyToOne(targetEntity = Parent.class, fetch=FetchType.LAZY) @JoinColumn(name="PARENT_ID", nullable=false)
Does that all make sense? Is there any excessive, non-functional annotation I can trim off?
|