-->
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: How do I know whether an object is associate with a session
PostPosted: Thu Jul 15, 2004 8:19 pm 
Newbie

Joined: Wed Feb 04, 2004 10:31 pm
Posts: 10
I am trying to load a lazily initialized collection. Sometimes (it is hard to tell because there is a wrapper handling hibernate stuff) the session associated with the object is closed and I get a LazyInitializationException.
I can fix this by calling
session.lock(item, LockMode.NONE);
and the collection works.

When try the acces the collection, catch the exception and reassociate all is well. However causing an exception and fixing the problem bothers me. I should be able to do something like this
if(objectIsNotAssociatedWithSession(session,item))
session.lock(item, LockMode.NONE);
The problem is I don't know how to test whether an object is associated with a session - hopefully without havine to cause an exception.

How do I do this???


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 15, 2004 9:57 pm 
Regular
Regular

Joined: Wed Nov 05, 2003 10:57 pm
Posts: 96
You can use session.contains(yourObject).

You may not need to used this method. Just associate your (unmodified) object, or the top object of a graph, with the new session, if the old session is closed and you need to get objects beyond what was loaded with the closed session.

Mota


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.