-->
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: Accessing lazy-loaded collections/proxies
PostPosted: Wed May 25, 2005 10:52 am 
Newbie

Joined: Wed May 25, 2005 10:41 am
Posts: 1
Are there any recommended patterns on using NHibernate in an ASP.NET Solution?

I am currently using NHibernate in a seperate assembly from my solution, in the assembly I do all my CRUD work. This was working well until I loaded up my database with prod data. The increase in data made the app crawl due to relationships between objects.

I switched to lazy=true and now, of course, I don't have a valid Session why I try to access object.

How have you handled this?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 27, 2005 9:55 am 
Contributor
Contributor

Joined: Thu May 12, 2005 9:45 am
Posts: 593
Location: nhibernate.org
You have two options when using lazy-loading :

1- You force the loading of the collections/proxies that you know you will need before closing the session
Example :
Code:
e = session.Load(...);
if(e.MyCollection.Count) {} // after this, the collection is loaded
if(e.MyProxy==null) {} // and here, the proxy is initialized
session.Close();


2- You re-attach the entity to an opened session, using session.Lock(e, None);

_________________
Pierre Henri Kuaté.
Get NHibernate in Action Now!


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.