-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: why session.lock() & still LazyInitializationException?
PostPosted: Thu Aug 05, 2004 3:17 pm 
Newbie

Joined: Mon Jun 21, 2004 11:58 pm
Posts: 5
Hibernate 2.1.4

I have an object 'A' which has a child object 'B' that is defined as a property. 'B' has a collection 'C' that is defined as lazy

I retrieve 'A' from a hibernate session, and the session is closed and 'A' "goes off and does some stuff"

Later 'A' is reattached to a "new" session with session.lock(A, LockMode.NONE) and I do 'B = A.getB()' and all is well

I then call 'B.getC()' and I get LazyInitializationException with "no session or disconnected session"

If I do session.lock(B, LockMode.NONE); after calling 'A.getB()' then I can call 'B.getC()' with no errors

I understood that if the parent object is reassociated with a session, so should the whole object graph? What am I missing?


Top
 Profile  
 
 Post subject: P.S.
PostPosted: Thu Aug 05, 2004 3:19 pm 
Newbie

Joined: Mon Jun 21, 2004 11:58 pm
Posts: 5
I'm not modifying 'A' in between getting it from the session and calling 'A.getB()' on it


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 05, 2004 4:11 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Depends on the cascade attribute. Lock only cascades across save-update (or "higher").


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.