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: Best Practice - Mapping Lookup Tables
PostPosted: Tue Apr 08, 2008 12:12 pm 
Newbie

Joined: Wed Dec 20, 2006 12:34 pm
Posts: 13
Hibernate version: 1.2
Database: MySQL 5.0

What is the best practice for mapping lookup tables? For example lets say i have a table called 'Account' and a table called 'Status'. Obviously the 'Account' table has basic account information and a status column. I need to map the Account table so that it contains a Status object. Should this be:

<one-to-one name="Status" class="Project.Status, Project" property-ref="Code"/>

Or

[b]<many-to-one name="Status" class="Project.Status, Project" column="STATUS" property-ref="Code" fetch="join"/>


It is important to note that an account can only have one status, it is not necessary to have a reference to the account in the status object, on an update of the Account object the status column of the account table should be updated but the Status table should never be changed. Essentially this is a basic look-up table situation where i have a secondary table of values and one of those values should be set in the primary table.

Any help much appreciated. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 10, 2008 12:02 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
I assume that the Status entity contains no Account-specific information; i.e. many Accounts can have the same Status. If that is the case, then you want something like this:

Code:
<many-to-one name="Status" class="Project.Status, Project" column="STATUS" cascade="none" />


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.