Hibernate version: 3.0.5
I am getting the "donot change reference to a all-delete-orphan collection" in the following scenario (pseudo code):
Code:
tx = session.beginTransaction();
session.save(objectGraphA); //goes thro fine
session.flush();
session.save(objectGraphB); // fails due to a data issue
session.flush();
tx.rollback(); //roll back due to the failure above
session.close
Both object graphs are sent back to the presentaion layer, where the data issue in objectGraphB is fixed . Then when I try to save the object graphs in a new session
Code:
tx = newSession.beginTransaction();
newSession.save(objectGraphA); //it fails is here
objectGraphA has a bag with cascade set to all-delete-orphan and hibernate thinks the reference has changed on that collection. I kind of understand whats happening:
since the first save goes thro fine, the bag changes to a PersistentBag. But when it gets rolledback eventrually, re saving the same object graph with the persistentbag confuses hibernate.
But how do i solve this issue? Any help would be greatly appreciated.