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).