-->
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: Lazy loading for many-to-one?
PostPosted: Thu Jun 24, 2004 8:29 am 
Newbie

Joined: Thu Jun 24, 2004 8:22 am
Posts: 7
Hi,

I would like to know if it is possible to activate lazy loading for a many-to-one association only, instead of setting lazy="true" for the entire entity.
If lazy="true" is set for the entity (that appears in the many-to-one), when executing a Hibernate query, all fields of this entity will automatically be populated, if the many-to-one relationship is defined in the hbm files.
In my application, I sometimes want the association data to be loaded, but in other cases, I don't need that extra data.

Is there any way this can be done?

Kind regards,
Johan


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 9:07 am 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Isn't the
Code:
lazy
attribute applicable for relationships. If I remember correctly, when you sent lazy true, and turn the SQL trace on, you'll see that the first SQL get's the columns from the parent. Once you try accessing the collection, it'll fire another query to get the child objects. Not sure if I answered your question.

-Anand


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 9:14 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
1- declare lazy = true on the class (not on the many-to-one declaration)
2- code a default constructor in your pojo

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.