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.  [ 3 posts ] 
Author Message
 Post subject: NHibernate Best Practicies
PostPosted: Wed Feb 06, 2008 6:02 am 
Beginner
Beginner

Joined: Fri Aug 10, 2007 3:34 am
Posts: 44
I have a question:
What is best? Leaving all lazy asociations true?

I know that if a i have an association that i always need to load
with an object then it's a good thing to make the association non-lazy

But there's an incovienence if i make an association non-lazy:
in HQL querys. When i query some data using HQL i don't usually
need that extra select or join for the association.

Is there a way of toggling betwing lazy - non-lazy at runtime?

Thank you,
Christian Constantinescu.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 11:45 am 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
You can override the fetch strategy using both the IQuery and ICriteria interface. See this section in the documentation:
http://www.hibernate.org/hib_docs/nhibe ... e-fetching

_________________
Karl Chu


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 06, 2008 6:02 pm 
Newbie

Joined: Mon Apr 30, 2007 6:17 pm
Posts: 14
>> I know that if a i have an association that i always need to load with an object then it's a good thing to make the association non-lazy

I will reluctantly accept that you can be certain that for every unit of work you ever do on object A you will also access the associated object B. Even so, what's the downside of leaving object B lazy? I do not usually ask, "why make it lazy," but rather "why not?" I'm not sure if this is a "best practice" or not, but it's worked pretty well for me so far.


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