This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Lookup tables and foreign keys. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Lookup tables and foreign keys." Watch "Lookup tables and foreign keys." New topic
Author

Lookup tables and foreign keys.

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Is this it possible, or should be done?

You have a table that has a foreign key to a "lookup" table. Say for instance Order Status. So in the Order Header table you have the Foreign Key to the Order status. Now on the client side the user wants to select a nice pretty String representation of the status, but you want to save the PK of that record in the Order Header Table.

Should you

A) Put both the ID field and the String into the POJO representing the Order Header.
----1) Would the client just put in the String and allow Hibernate to find the FK?
----2) Or would the client be required to put in the FK?
B) Keep just the ID field and the client has to do a lookup to the database?

Can Hibernate solve this kind of issue?

Thanks

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
Don't get me started about those stupid light bulbs.
 
subject: Lookup tables and foreign keys.
 
Similar Threads
Best mapping approach for reference/LOV/lookup data
reverse engineering a one to one relationship
Hibernate 3 Annotations
insert new parent/child row. How to handle new primary/foreign key inserts
Hibernate - Mapping foreign keys tables