eladm wrote:
Hello All
I am a Hibernate newbie, and now looking for solution to handle my lookup tables. I mean those tables with 2 columns for id and name, such as country (1, "USA").
I searched and encountered some solutions that describe the use of a class for the lookup table.
Now - I think it is a pure waste. I do not regard the "country" table as an entity, but merely a warehouse for holding the list of countries, and for normalization. I really have no use to a "Country" class..
Further more, in my object model, I would really like to see I.E. in my "Contact" class a field of country of type String. Because I am interested in the country name...
Because I am also building a GUI, and would like to allow my user to have a "select box" of countries, I would also have something like "getCountries()" in my "Contact" class, to return a map of ID's, and String objects - with the county names.
My question is - Is there a way do achieve that using Hibernate, and if not - why ?
What is your objection to having an Object that is a country ? Since it's reference data that probably won't be updated often you can aggressively cache these objects using the second-level cache.
If you want to maintain the relationship of id and name in a collection, don't you need an object ?