This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cascading delete

 
Bob Lawson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bob Lawson
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey - i got it worked out. here was my problem:

https://forum.hibernate.org/viewtopic.php?t=924490
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic