-->
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: Serializing and deserializing ISession?
PostPosted: Fri Sep 01, 2006 12:03 pm 
Newbie

Joined: Fri Apr 21, 2006 5:33 pm
Posts: 12
Hi guys,

This is a bit different, so bear with me!

I'm attempting the following:
1) Create an ISession
2) Manipulate some business domain objects
3) Serialize the ISession
4) Commit/Flush the changes to the db
5) If an exception occurs, restore the ISession from it's serialized state (so that I don't lose the ISession's contents)

I've successfully serialized and then deserialized the session, but all of my domain objects no longer perform lazy-loading. I get a "LazyInitializationException: Failed to lazily initialize a collection - no session" message. I've reconnected the ISession after deserializing it, but it still doesn't want to play.

Could it be that the proxies are bound to the original ISession? If so, how does one re-establish the binding to a new ISession? Bear in mind that I want to retain the dirty status of the ISession, and all of the dirty objects within it.

Any ideas?
Thanks.


Top
 Profile  
 
 Post subject: Re: Serializing and deserializing ISession?
PostPosted: Mon Sep 04, 2006 9:21 am 
Beginner
Beginner

Joined: Wed Aug 03, 2005 8:06 am
Posts: 40
Location: Netherlands
Vij wrote:
restore the ISession from it's serialized state


As far as I know NHibernate, the problem seems to be that you still create a new instance of an ISession. There is no way to tell all PersistenCollections of your domain objects that this has happened. as far as your domain objects are concerned, the session they were constucted by is closed and they are not aware of the 'resored' session. I think you can'tavoid the pain of getting a new session from your factory and do SaveOrUpdate with your existing domain objects.


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.