-->
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: How to avoid unncessary selects when having combo boxes?
PostPosted: Sat Nov 27, 2004 4:43 am 
Senior
Senior

Joined: Sat Nov 27, 2004 4:13 am
Posts: 137
Hi
Hibernate promises that it lets us use correct object model.

In my application I have some code-description types which are referenced by some other objects (for example country for an address), what is the best practice to reference to these objects in web GUI?

I use combo boxes in web tier, and use the primary key of referenced object as value for combo box. Must I retrieve the code-description object using its primary key and then assign it to other objects? I think this is agains performance.

for example:

Code:
public class Country{
  private Long id;
  private String name;
  ...
}

public class Address{
  private Long id;
  private Country country;
...
}


should I do as follow:

Code:
   Coutnry country = (Country)session.get(country.class, countryId);
   address.setCountry(country);
   session.save(address);


or can I do the job without retrieving the Country object (which is not necessary, because only its primary key is needed in updating the database).

_________________
don't forget to credit!

Amir Pashazadeh
Payeshgaran MT
پايشگران مديريت طرح
http://www.payeshgaran.co
http://www.payeshgaran.org
http://www.payeshgaran.net


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 27, 2004 11:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Make country proxyable and use load in the code you posted


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.