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 on Layered Architecture
PostPosted: Fri Aug 11, 2006 12:02 am 
Newbie

Joined: Thu Aug 10, 2006 11:46 pm
Posts: 3
Hi,

I'm a newbie getting around with nhibernate 1.0.2 lazy loading. I have a sample app with BusinessFacade -> Business Rules -> DAL each on a separate assembly. If I specify on the mapping files not to lazy load it works just fine but when I tried specifying lazy loading then the collection properties of the object obtained are empty. Could this be because I'm passing the object obtained from NHibernate process through the layers? (from DAL->BR->BF).

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 11, 2006 4:40 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
No, has nothing to do with your code layering. In order to have lazy loading working you have to keep the session open after your first initial loading of the object. I also suspect that you are "swallowing" an exception there this is why you end up only with empty collections.

cheers,
radu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 13, 2006 10:14 pm 
Newbie

Joined: Thu Aug 10, 2006 11:46 pm
Posts: 3
radu wrote:
No, has nothing to do with your code layering. In order to have lazy loading working you have to keep the session open after your first initial loading of the object. I also suspect that you are "swallowing" an exception there this is why you end up only with empty collections.

cheers,
radu


Thanks for your reply.

I stepped through the code and enumerate one of the collection right after loading and display the output to the console just to make sure that the session is open. As expected the collection is not populated and the session is open.

I also enclosed the loading with the try catch block and display to the console whatever exception was thrown unfortunately there was no exception that was being thrown out.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 14, 2006 6:23 am 
Senior
Senior

Joined: Wed Jun 15, 2005 4:17 am
Posts: 156
in this case you should post some mappings and code which exhibit the problem.

radu


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.