posted 13 years ago
I have a very large aggregation of domain entities, where one top object contains one-to-many of others, which themselves contain one-to-may of others, etc, etc. To annotate each relationship, I am using:
@OneToMany(fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
However, when I try to delete the top object, I get a DataIntegrityViolationException because apparently the objects underneath would become orphans if the top were deleted. I also tried:
@Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
But got the same problem. This should be easy in Hibernate, so I'm sure there is something simple I am missing. Any help? Thanks.