• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Hibernate - ObjectDeletedException: deleted object would be re-saved by cascade...

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I have a parent class(Person) and a child class (UploadedFile)
All updates, inserts work fine but deletes do not. I get this error

i get this error
ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)

if this is called
person.getPhotos.remove(0);
and then this is called
session.update(person)

Does the child UploadedFile need to have a person reference as this is what I see on the net?
But is there anyway to avoid this as I think it is over kill
I tried inverse="true" and insvers="false"




 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this

https://forum.hibernate.org/viewtopic.php?p=2350533

Are you removing the object from all collections?

It shouldn't be related to needing to make it bi-directional.

Usually the best approach is to remove the object from the collection, then update/save the parent object. The cascade option on the collection and Hibernate seeing it has been removed from the collection will tell hibernate to delete the removed object.

Mark
 
Ally Cavs
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mark,

Yes i onky store the object in this collection.
Now i remove the object in one struts action
Another struts action handles the saving

So struts action 1
calls
person.getPhotos.remove(0);

while a second action calls
person.getPhotos.remove(0);

I dont think this is a problem
but I am really stumped at this issue. Can someone please show me what to do or a working example please?

Thanks
Ally
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic