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.  [ 9 posts ] 
Author Message
 Post subject: Lazy class Initialization problem
PostPosted: Wed Oct 25, 2006 12:47 pm 
Beginner
Beginner

Joined: Fri Oct 20, 2006 8:02 am
Posts: 36
Hi.
I'm using NHibernate em Remote Object to create my Application Server.

But I'm having problem on pass a lazy class to a Client Application .

I don't know how to don't Initialize a lazy class when the remote object serializes it to send to the Client application.

Is there anybody with the same problem and whose soved it?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 7:28 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
Either set lazy=false, or use FetchMode.Eager in your criteria query, or call NHibernateUtil.Initialize on the collection.


Top
 Profile  
 
 Post subject: Lazy class, not lazy collection
PostPosted: Tue Oct 31, 2006 4:29 pm 
Beginner
Beginner

Joined: Fri Oct 20, 2006 8:02 am
Posts: 36
Hi. here is the problem.
When the client side ask for some object (Obj) that contains a many-to-one property (LazyClassProp), this property doesn't come initialized becouse it's class is lazy.
But when the remote object serializes this object (Obj), the serializer tries to initialize it, and I don't know why the serializer does.
I don't want it, I want the object (Obj) goes to the client side with that property not initialized, so, when the property whith the lazy class is accessed into the client, the remote object intercepts the initialization and request the initialized object.

I don't konw how to do this.


Last edited by anuarneto on Tue Oct 31, 2006 4:32 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 4:32 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
So you want the client and server side, both sides, to connect to the database and load properties of the same object?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 31, 2006 4:38 pm 
Beginner
Beginner

Joined: Fri Oct 20, 2006 8:02 am
Posts: 36
No, just the server side gets to the database by nhibernate.

But, just de client side asks a proxyed class to be initialized.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 01, 2006 11:48 pm 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
Im still not quite sure what you want, but the bottom line is that when the object is serialized, the opportunity for lazy loading has passed. Either the child objects get serialized or they don't. You'll have to add the feature to the interface to let the client specify whether or not it wants the child objects.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 06, 2006 11:43 am 
Beginner
Beginner

Joined: Fri Oct 20, 2006 8:02 am
Posts: 36
What I want it, that the object not to be initialized at the first time.
But later, if i need, I send it back to be Initialized. but it throws an exception during the firt serialization.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 1:16 am 
Regular
Regular

Joined: Thu Aug 24, 2006 2:05 am
Posts: 80
if you are using XMLSerializer then apply attribute XMLIgnore at you Collection object property.
Lets say you have Patient class which contains IList collection for Prescriptions(i.e.PrescriptionList) then apply "XMLIgnore" attribute to PrescriptionList so that while applying serialization, it will ignore PrescriptionList.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 07, 2006 9:04 am 
Senior
Senior

Joined: Sat Mar 25, 2006 9:16 am
Posts: 150
But then he wants to exchange the object again and the next time, he does want it to be serialized, so an attribute won't work.

He can just null out the property reference before serialization if he doesn't want to serialize it. However this requires the client to specify whether or not it wants the property loaded.


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