I have a graph with many levels of parent-children. I modeled this graph with lazy initialization. I need to load the top part of this graph in one session, modify it when necessary, and if needed load other sets of children in new subsequent sessions. At the end I cascade-update the whole graph.
Hibernate documentation specifies:
"The lock() method allows the application to reassociate an unmodified object with a new session." section 8.6.
Gavin said:
"For unmodified objects: session.lock(o, LockMode.NONE)
For modified objects: session.update(o)" in this thread:
http://forum.hibernate.org/viewtopic.php?t=926239&highlight=
I don't want to persist the changes to the loaded part until I am done (not just to lazy initialize a collection).
I was able to load children of a modified parent, without losing the changes to the parent with the following code:
session.lock(parent, LockMode.NONE);
if(!Hibernate.isInitialized(parent.getChildren())){
Hibernate.initialize(parent.getChildren());
}
What am I missing?
mota