-->
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.  [ 4 posts ] 
Author Message
 Post subject: one-to-many, set keyword diff between foreign-key & colu
PostPosted: Fri Mar 05, 2004 12:02 pm 
Newbie

Joined: Wed Feb 11, 2004 6:04 pm
Posts: 11
Location: Houston
Sorry about this stupid question ...

When specifying a one-to-many relation I wonder how I can reference a column name in the parent to a coulmn name in the child which do not have the same name.

(NAME is the column name in the Child Table which links to the column name PARENT_NAME in the Parent)

In my parent mapping I have:

<set name="values">
<key foreign-key="NAME"/>
<one-to-many class="com.xyz.Child"/>
</set>

A) what is the difference in using

<set name="children">
<key>
<column name="NAME" />
</key>
<one-to-many class="com.xyz.Child"/>
</set>

B) Do I just have to add a <many-to-one> block in the Child mapping file like
<many-to-one
name="parent"
class="com.xyzl.Parent"
>
<column name="PARENT_NAME" />
</many-to-one>

to get the relation between NAME in the Child and PARENT_NAME in the Parent to work ?

Thanx
B

_________________
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 12:16 pm 
Newbie

Joined: Wed Feb 11, 2004 6:04 pm
Posts: 11
Location: Houston
To answer myslefe ... redaing the documentation the
<key column referres to the parent key to be used as fk

So maybe the anwser is to use in the pafrent mapping something like

<set name="values">
<key column="PARENT_NAME"/>
<key foreign-key="NAME"/>
<one-to-many class="com.xyz.Child"/>
</set>


?

_________________
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 12:22 pm 
Newbie

Joined: Wed Feb 11, 2004 6:04 pm
Posts: 11
Location: Houston
I ment of course

<set name="values">
<key column="PARENT_NAME" foreign-key="NAME"/>
<one-to-many class="com.xyz.Child"/>
</set>

_________________
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 05, 2004 3:39 pm 
Newbie

Joined: Wed Sep 22, 2004 12:18 pm
Posts: 14
Im not sure if you can achieve what you want, i.e. join on a column in the parent table other than the primary key...I ran into the same problem, and don't think there's a solution...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.