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.  [ 4 posts ] 
Author Message
 Post subject: Lazy Loading Problem.
PostPosted: Fri Jun 13, 2008 7:02 am 
Newbie

Joined: Fri Jan 25, 2008 6:18 am
Posts: 10
Location: Bangalore, India
Hi folks,

I have converted my project into nHibernate. This is n-tier architecture. I am doing all nHibernate operations in Data Access Layer. So all my Sessions (Session per method call) will open in DAL (Data Access Layer) and fill the required entity and session will be closed there after this my captured entity will be returned to my BL-> Presentation Layer.

I hope you understand the scenorio, then when I am trying to load related entity, then it is giving "Lazy - Session Closed" exception. when I keep "default-lazy = true" in my mapping files. but if I change the same to "default-lazy = false", then I am getting the result but it is taking much time to load all related entities.

can any one help me how to increase the performance, and get the related entity when ever I required.

plese help me .........

_________________
Thanks & Regards
Babar Shaik.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 13, 2008 3:52 pm 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
When you load the object lazyily you will have the better performance..

You can do it in the Class level to initialize the child objects instead of configuring in the hibernate xml.
like Hibernate.intialize(collections).

Using Lazy loading is tricky..do it properly...
For eg.,
If you want to show a search of list of employee who has so many addresses associated to him, then getting the addresses object on the search list of employee is not required, so do lazy loading. But if you want to show the detail of an employee, most of the cases you might require the address object, so load the child object...

Hope this helps...If not explain ur scenario...

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 6:25 am 
Newbie

Joined: Fri Jan 25, 2008 6:18 am
Posts: 10
Location: Bangalore, India
Hi ramnath,

I am sorry!. Actually I didn't get what you are saying. I didn't get the method NHibernate.initialize(collection), where I am using NHIbernate.

can you please elaborate on the Same.

_________________
Thanks & Regards
Babar Shaik.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 9:48 am 
Expert
Expert

Joined: Thu May 26, 2005 9:19 am
Posts: 262
Location: Oak Creek, WI
Hi,

Use this..
NHibernateUtil.Initialize(collections)

Look into the below link for more directions..

http://www.hibernate.org/hib_docs/nhibe ... mance.html

Let me know if you still face problems..

_________________
RamnathN
Senior Software Engineer
http://www.linkedin.com/in/ramnathn
Don't forget to rate.


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