Enable loading of collections thats been detached from session
Description
Activity

Brett Meyer March 7, 2014 at 10:09 PM
Bulk closing tickets resolved in released versions

Stephan van Hugten December 12, 2013 at 8:09 AM
Why is it incorrect to (re-)use the current session there? If it is still open it could save some database calls right?
Steve Ebersole December 11, 2013 at 4:10 PM
1) We could leverage isConnectedToSession()
instead. But notice that your proposed exception message is (potentially) completely wrong; there may in fact be a Session, but it might be closed, etc. We did the separate checks to make the exception message as specific as possible.
2) It is absolutely incorrect to use a "current session" here.

Stephan van Hugten December 11, 2013 at 2:55 PM
I'm wondering why this isn't done via the logic in AbstractPersistentCollection:isConnectedToSession()?
So instead of:
AbstractPersistentCollection.java
use:
AbstractPersistentCollection.java
I'm also wondering why you're opening a new session while the Session Factory may still have a current session? This might cause HHH-7524.
In the code I also see that you're only adding the actual collection to a new session with
AbstractPersistentCollection.java
What if it is a child collection? When I wrote my own patch for this problem (Guilty!) I got problems with the fact that a child collection added this way without its owner would be marked as dereferenced and deleted( ! ).
To be complete, this is my code (using Spring):
AbstractPersistentCollection.java
StaticBeanRegistry is a singleton holder of the Application Context via the ApplicationContextAware interface.
(Using version 4.2.7.SP1, upgraded from 3.6.9)

Andreas Joseph Krogh August 14, 2012 at 1:34 PM
Issue created. I don't know yet what kind of associations causing this. I'll create a test-case this evening if nobody beats me to it. Let's move further discussion to the new issue.
This will enable collections thats not loaded and outside the session scope to be loaded.
Note: this may happen outside of the transaction and is not safe. Use with caution.