-->
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.  [ 1 post ] 
Author Message
 Post subject: One-to-many where foreign key != primary key
PostPosted: Tue Aug 11, 2009 4:10 am 
Newbie

Joined: Thu Aug 06, 2009 10:59 am
Posts: 6
In my database I have a table with a primary key, id, and a set of fields one of which is a varchar field named username. A second table has two varchar fields username, authority as a composite primary key. username from the first table is used to match username in the second table to retrieve multiple values for authority. In my hibernate mapping file I have the following:

Code:
<id name="id" column="id">
   <generator class="native" />
</id>
<property name="username" />
<!-- more properties... -->

<set name="authorities" table="authorities">
   <key column="username" foreign-key="username"
   <element column="authority" type="string" />
</set>


I ran a test with this mapping and the result is that the value from the id field of the first table gets inserted into the username field of the second table. What I need is for the value of the username field of the first table to be inserted into the second table.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.