-->
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.  [ 8 posts ] 
Author Message
 Post subject: Not load some attribute when loading an object
PostPosted: Tue Nov 25, 2003 6:41 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
Dear All,
I would like not to load some attribute when I load an object (a kind of lazy mode but for attributes) : is it possible and how can I do ?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 7:28 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
I haven't tried this but I'm guessing that you could map the attribute as a one-to-one relationship (perhaps even to the same table) and that the DB would only be hit when you reference the 'related' object. (remembering to set outer join to false on the relationship)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 7:35 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
You could also use a class hierarchy (inheritance) and loading the type corresponding to the level of detail you need.

Example:
CustomerInfo: containing customer's name and id
Customer extends CustomerInfo: with link to ordered items

When loading your customer, choose to load CustomerInfo or Customer depending on what you need...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 8:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
See the "lightweight class" pattern on the Wiki.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 9:36 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
gavin wrote:
See the "lightweight class" pattern on the Wiki.


Wiki ????????????????????


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 9:39 am 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
http://www.hibernate.org/41.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 10:09 am 
Regular
Regular

Joined: Thu Nov 20, 2003 10:44 am
Posts: 58
Location: Paris, France
brenuart wrote:


Ok thanks but it is a little bit heavy to handle, it should be a good idea to add some attributes in the XML mapping to allow not to load some attributes of an object


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 25, 2003 10:25 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
This is not possible to implement w/o buildtime bytecode tricks.

And anyway it is a horribly inefficient thing to do, most of the time - it exposes you to n+1 selects problem whenever you do actually need the extra attributes.


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