-->
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.  [ 1 post ] 
Author Message
 Post subject: Exception on Deserializing the DetachedCriteria
PostPosted: Wed Sep 10, 2008 3:49 am 
Newbie

Joined: Tue Aug 26, 2008 7:25 am
Posts: 12
Hello,

I need to save my DetachedCriteria and load it later (I'm developing a query builder application). For this, I am using serialization/deserialization through the NHibernate.Util.SerializationHelper utility class.

More precisely, when I save the criteria I'm using
"bytes = SerializationHelper.Serialize(this);" and then save these bytes into a file. When deserializing it, I'm using "SerializationHelper.Deserialize(bytes)". All that is working fine if the DetachedQuery is not run before serializing it. I mean, if before serialization happens, the following lines are executed:

NHibernate.ISession s = QueryBuilder.SessionFactory.OpenSession();
ICriteria crit = criteria.GetExecutableCriteria(s);
IList results = crit.List();

('criteria' is my DetachedCriteria to be saved))

...in this case, I believe some of the session data (or session factory) are serialized too. And when trying to Deserialize the DetachedCriteria, it throws an exception.

Please help me finding a way to proper serialize this DetachedCriteria.It may be possible that the criteria be run before it is saved, so I have to know how to workaround this issue.

Below is the exception thrown when the criteria is deserialized using "SerializationHelper.Deserialize(bytes)".

Thanks in advance!

Message: "Key cannot be null.\r\nParameter name: key"

StackTrace:

" at System.Collections.Hashtable.get_Item(Object key)\r\n at NHibernate.Impl.SessionFactoryObjectFactory.GetNamedInstance(String name)\r\n at NHibernate.Impl.SessionFactoryImpl.GetRealObject(StreamingContext context)\r\n at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)\r\n at System.Runtime.Serialization.ObjectManager.DoFixups()\r\n at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)\r\n at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)\r\n at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)\r\n at NHibernate.Util.SerializationHelper.Deserialize(Byte[] data)\r\n


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.