• 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

Hibernate error when deleting child objects when parent object is deleted

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have searched these forums and couldn't find a solution to my problem. Please excuse me if this question has been asked before.

I am currently experiencing a problem on on a spring web application I am developing.

I have 3 entities: Person, Team and TeamMembership, which is just a link entity to break up the ManyToMany relationship between Person and Team into two OneToMany relationships. Initially, I had the Team and TeamMembership delete working correctly whereby if I deleted or updated a Team, the TeamMemberships would be automatically deleted or updated correctly. However when I introduced the Person entity, it stopped working correctly. I get a Hibernate exception saying that the deleted object would be re-saved by cascade

I want it to work such that if I delete a Team or Person object, the corresponding TeamMemberships will be orphaned and deleted. Please assist.

Code samples as follows.

Person:


Team:


TeamMembership:


Code I execute is:


The exception is get is:
org.springframework.dao.InvalidDataAccessApiUsageException: deleted object would be re-saved by cascade (remove deleted object from associations)
 
Ranch Hand
Posts: 108
Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if this

is called before
?
 
You got style baby! More than 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