-->
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: turning lazy loading on/off dynamically?
PostPosted: Wed Sep 13, 2006 11:49 pm 
Newbie

Joined: Wed Sep 13, 2006 11:44 pm
Posts: 2
dear hibernate experts,

i have a User class with a list of UserImages. sometimes i want the UserImages loaded non-lazy (to avoid n+1 selects) and sometimes i want them loaded lazy. can you please point me to the right part of the documentation? i cannot find anything. perhaps i am a google idiot. thank you.

adam


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 2:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Make sure the relationship is lazy and use a query that include the fetch to tell hibernate to not lazy load it.

Lazy: from User;
Non-lasy: select u from User u left join fetch u.userImages;

See http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-fetching for more information.


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.