If you load a User instance into the Session context it becomes _detached_ from 
the persistence context, by definition (the persistence context has a smaller 
scope, Conversation or Event). 

So if you want to access unloaded associations or collections on that User 
instance you need to _reattach_ it or _merge_ it into a new persistence context 
at the time you want to initialize associations or collections. This means you 
need to pass the instance into the entityManager.merge(user) method, then take 
the return value and access your collection there.

I recommend that you instead:

a) do not access the collection of the User instance in the Session but instead 
put the "currentPhoneNumbers" list into the Session as well and access it 
directly

b) map the one-to-many with EAGER fetching so the collection is loaded right 
away when the User is loaded


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083299#4083299

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083299
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to