• Post Reply Bookmark Topic Watch Topic
  • New Topic

Solution for cascade="all-delete-orphan" in hibernate

 
Kumar N Krishna
Greenhorn
Posts: 10
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: src.Parent.childSet
at org.hibernate.engine.Collections.processDereferencedCollection(Collections.java:96)
at org.hibernate.engine.Collections.processUnreachableCollection(Collections.java:39)
at org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:218)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:77)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at src.TestDAOImpl.saveObj(TestDAOImpl.java:31)
at src.HBTest.main(HBTest.java:17)

Problem is ::



Solution is: we have to clear previous child collection explicitly and add new Child objects



cascade="all-delete-orphan"
A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure what you are showing here. Could you not just initialise the association? Why do you need a new collection?
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!