-->
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.  [ 5 posts ] 
Author Message
 Post subject: Serialization and lazy="true"
PostPosted: Thu Oct 05, 2006 3:59 pm 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
Hibernate version:1.2.0Beta

I cannot serialize objects that have children with lazy loading enabled. Here is the error I get:

System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: CProxyTypePaymentTypeDomains_INHibernateProxy_ISerializable2 cannot be serialized because it does not have a parameterless constructor.

When I turn lazy loading off in the child objects the error goes away. Is there a way to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 05, 2006 7:43 pm 
Beginner
Beginner

Joined: Wed Jul 05, 2006 12:45 pm
Posts: 21
I have seen a Spring filter which cleans out any references to non-initialized proxies (which are causing your error). If you can live without serializing the actual proxy (i.e. that property would be null), then have a look at this:

http://blog.murf.org/2005/04/06/lazy-lo ... -cleanser/

I believe this is for Java, but you can look at the source code and adopt to your needs in .NET.

-Sasha Borodin


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 12, 2006 4:59 pm 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
The cleanser looks like it was created to fix a 'similar' problem but what I really need is something that does the exact opposite. I want objects that have lazy="true" and have not yet been loaded to be serialzed as well. Thus far we have just been touching a property in each object which will cause it to be loaded, but it is a far-from-ideal solution for sure.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 11:06 am 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
I can write my own little method to go through and cause a property to become lazy loaded. Does anyone know of a way to cause something to be lazy loaded without having to attempt to read a value?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 2:19 am 
Contributor
Contributor

Joined: Sat Sep 24, 2005 11:25 am
Posts: 198
Yes, use:

NHibernateUtil.Initialize( lazyObject );


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