我正在尝试以“一个”作为父级建立双向一对多关系
我有一个家长:
@Entity
public class VideoOnDemand {
@OneToMany(cascade = CascadeType.ALL)
@LazyCollection(LazyCollectionOption.FALSE)
@JoinColumn(name = "video_id")
private List<CuePoint> cuePoints = new ArrayList<CuePoint>();
}
和一个孩子:
@Entity
public class CuePoint {
@ManyToOne(cascade=CascadeType.ALL)
@JoinColumn(name = "video_id", insertable = false, updatable = false)
private VideoOnDemand video;
}
我使用了来自官方 Hibernate文档(2.2.5.3.1.1) 的建议。但是,Hibernate 似乎不理解 CuePoint 是一个子实体,因此,当我删除 CuePoint 时,它也会删除 VideoOnDemand 以及所有其他 CuePoints。
我做错了什么,正确的方法是什么?