I'm trying to setup a bi-directional one-to-many relationship with "one" as parent
I have a parent:
@Entity
public class VideoOnDemand {
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name = "video_id")
private List<CuePoint> cuePoints = new ArrayList<CuePoint>();
}
and a child:
@Entity
public class CuePoint {
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "video_id", insertable = false, updatable = false)
private VideoOnDemand video;
}
I used recommendations from the official Hibernate documentation (2.2.5.3.1.1). However, Hibernate doesn't seem to understand that CuePoint is a child entity, so, when I delete the CuePoint, it deletes VideoOnDemand as well with all the other CuePoints.
What am I doing wrong and what is the right way?