Hello,
How does lazy loading of collections work across sessions?
I have an object that I load in one session using session.find(....);
It has several collections that are defined with the lazy="true" attribute.
In another transaction, I want to be able to access certain (but not all) of the lazy collections.
I do the following:
// open the session
session.save(myObject); // this appears to lazy-initialize all the collections!
myObject.getACollection();
if I don't do session.save or load or update, then I get an exception that says it failed to lazy initialize the collection - no session.
If I do a session.save, load, or update, then it intializes all the lazy collections.
Is this the way it is meant to work? It seems the only way a lazy collection works is if you find the object within the same session as the one you access the collections within.
Thanks in advance,
-Ben
|