-->
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: Cannot initialize proxies after lock
PostPosted: Wed Nov 24, 2004 1:11 pm 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
I thought that when you call Session#lock on a detached object that it reattaches it and allows you to access related objects that an earlier session had not initialized. But when I try to do this, I'm getting an exception. My code looks something like this:

Code:
SomeObject someObj = ...;   // initialized in a session

// ... At this point, the session is closed, so the object is detached.

Session newSession = ...; // open a new session
newSession.lock(someObj, LockMode.NONE);
Object relatedObj = someObj.getRelatedObject();


Seems like this should work, but I'm getting a HibernateException: "Could not initialize proxy - the owning Session was closed". The call stack indicates it was thrown by the related object's proxy. What's the problem?

Using Hibernate 2.1.6.

Thanks!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 1:24 pm 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
Same problem if I call refresh instead of lock.

I don't have to call lock on the related object proxies, too, do I? That would make it unfeasible to arbitrarily traverse an object graph that was partially built in a prior session. :(


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 1:50 pm 
Regular
Regular

Joined: Thu Oct 07, 2004 4:45 pm
Posts: 92
My mistake. I misused a Spring transaction proxy, so the new session was in fact closed by the time I tried to get the related object. Thanks anyway.


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.