-->
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.  [ 4 posts ] 
Author Message
 Post subject: Asyncronous Operation with proxied object
PostPosted: Mon Nov 14, 2005 2:19 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
I have situation where I am starting an asynchronous operation and passing two persistent entities to the asynchronous operation. The persistent entities may have some assosciations that havent been loaded yet. So I need to start a new session within the asynchronous operation so that I can lazy load the assosciations.

I have tried to attach the persistent objects to the new session with Lock, but I get an NHibernate.LazyInitializationException. The error message is "Illegally attempted to associate a proxy with two open Sessions".

So I am wondering if it is possible to associate an object with another session without evicting it from the first session.

Or if there is a better solution to solve my problem. thanks for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 3:06 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Which of the multiple sessions (and transactions) should the object then use to load itself?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 3:19 pm 
Senior
Senior

Joined: Sat Sep 10, 2005 3:46 pm
Posts: 178
The object could be potentially be loaded by both.

So it sounds like I need two instances of the object, one for each session. Is there any way to do this without re-loading the object from the database?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 14, 2005 5:43 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
If it could be loaded by both sessions, it could break transaction isolation.

NH does not have any API for copying objects, you have to do it yourself. Or if you have the second-level cache enabled, you can just try loading the object by id, it should be reloaded from the cache.


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