-->
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: many-to-one mapping with non pk
PostPosted: Thu Sep 11, 2003 9:27 pm 
Regular
Regular

Joined: Wed Sep 10, 2003 2:26 pm
Posts: 56
Location: San Diego, CA
hi,

I have a lookup table with the following structure:


CREATE TABLE payroll_title (
payroll_title_id int(11) NOT NULL auto_increment,
code varchar(4) NOT NULL,
name varchar(30) NOT NULL,
PRIMARY KEY (payroll_title_id)
);

and a corresponding mapping file:

<hibernate-mapping>
<class name="edu.ucsd.som.PayrollTitle" table="payroll_title">
<id name="id" column="payroll_title_id" type="long">
<generator class="native"/>
</id>

<property name="name" column="name" not-null="true" type="string" />
<property name="code" column="code" not-null="true" length="4" unique="true" type="string" />

</class>
</hibernate-mapping>

other tables should link to the payroll title table using the code field, not the primary payroll_title_id key. Is such setup possible?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2003 9:54 pm 
Regular
Regular

Joined: Wed Sep 10, 2003 2:26 pm
Posts: 56
Location: San Diego, CA
never mind. I've been banging my head against this for two days, but 10 minutes after posting the question I realized what the solution is.

Here's a new mapping file that solve my problem:

<hibernate-mapping>
<class name="edu.ucsd.som.PayrollTitle" table="payroll_title">
<id name="code" column="code" type="string"/>

<property name="name" column="name" not-null="true" type="string" />

</class>
</hibernate-mapping>


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.