Hi,
I am trying to saveOrUpdate an object using Hibernate 3.0 and I occasionally get database deadlock exceptions (from SQL Server 2005). The object has some one to many relationships with other classes and the saveOrUpdate cascades through these relationships. The related objects also have some one to many relationships.
What I want to do when the database exception occurs is to create a new session and try to save my object with that session. If I try to attach my object to the new session, I get a failure because some of the related objects have not been saved yet and have no ID.
Is the solution for me to traverse the object tree and exlicitly save all unsaved objects and then try to attach the parent object? Is there a simpler solution?
Any guidance would be appreciated.
|