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

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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic