-->
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.  [ 2 posts ] 
Author Message
 Post subject: Lazy Initialization in Collection and Session
PostPosted: Tue Apr 06, 2004 4:44 am 
Beginner
Beginner

Joined: Thu Dec 04, 2003 3:47 am
Posts: 31
Location: Hong Kong
I have a class A, with a Set of references to class B (using lazy initialization) In Session X, I get dataobject a (class A). Then, session X is closed. Later I open a new Session Y, and I try to iterate the references to class B in dataobject a. Lazy initialization exception (no session or session closed) throw.

I would like to ask, in previous example, does it means that I cannot iterate other objects from object a (with lazy initialization) in another session? If it is the case, if the object a has to be used for long time, (while the session is short-lived), i can't use lazy initialization? (since when I iterates other objects from object a, the session retrieving object a previously may have been closed). Or any suggestion or workaround?

I'm using hibernate version 2.0.3


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 6:35 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You have to reattach the object (session.lock(myObject, LockMode.NONE)
I'm not sure this API exists in 2.0.3, so you can use session.update(myObject).

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.