• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cascading delete

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey - i got it worked out. here was my problem:

https://forum.hibernate.org/viewtopic.php?t=924490
 
No matter. Try again. Fail again. Fail better. This time, do it with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic