-->
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: 1-many, many-1 with differnt column names - need example
PostPosted: Fri Mar 05, 2004 7:18 pm 
Newbie

Joined: Wed Feb 11, 2004 6:04 pm
Posts: 11
Location: Houston
After browsing around on the froum I have found lots of people having this problem but no clear example.

Suppose I have a Parent and Child in classic one-to-many and many-to-one relation. The relation is NOT using the same column name. So, how do I specify the one-to-many block in the parent mapping file and how the many-to-one in the child mapping file ?

Do I need to use propety-ref ?

Let's say the Parent's PARENT_ID maps to the childs CHILD_ID and visa versa.

B-)

_________________
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 7:27 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I don't get your problem. Where do you get the impression that you need the same column name for a many-to-one? many-to-ones allways are between the id column in the parent and the child table column you specify in your mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 10:30 pm 
Newbie

Joined: Wed Feb 11, 2004 6:04 pm
Posts: 11
Location: Houston
Sorry, I was not clear enough. Suppose there is a case where the id column is not the one to be used to link the parent to the child.

Example

Parent table:

PARENT_S (the primary key)
NAME
PARENT_ID

Child table:
CHILD_S (the primary key)
FATHER_ID
SIZE


the one-to-may shall now bee made via PARENT_ID to FATHER_ID

and the many-to-one the FATER_ID to PARENT_ID

HOW do I specify such a situation ?

Thanx
B-)

_________________
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 10:33 pm 
Newbie

Joined: Wed Feb 11, 2004 6:04 pm
Posts: 11
Location: Houston
And in the example above the PARENT_S is used as "id" for the Parent table and the "CHILD_S" is used as "id" in teh child table.

_________________
B-)


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.