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: NHibernate, Remoting and lazy initialization
PostPosted: Thu Dec 14, 2006 8:09 am 
Newbie

Joined: Wed Oct 18, 2006 8:47 am
Posts: 3
Hi,

I setup my DAO Hibernate layer as .Net Remoting service hosted on IIS. I'm able to get Hibernate entities but when I try to access property which has lazy attriubute in mapping file, I recive error that session is not intializated...because session was created on remote machine.

Is there any way to benefit from lazy intialization via .Net Remoting or it's not possible.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 15, 2006 9:14 am 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
You should never rely on lazy loading to retrieve your object. If you do this, you will end triggering maybe 1000 selects instead of one, which may a noticeable impact on performances, as you guess.

This is known as the "n+1 syndroma", imagine you have a Client that has an account, if you don't take care of retrieving client and their accounts with a sql-join, then iterating on the clients and accessing their accounts will trigger say 1000 selects if you have 1000 clients for example (and imagine the multiplication what if you access something related to the account...). So, you should care about loading all the graph you need in the client side, and throwing a new query only when it was planned, or normal, not because of the lazy loading feature.

HTH

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.