-->
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> using composite columns
PostPosted: Thu Jan 25, 2007 4:55 pm 
Newbie

Joined: Thu Jan 25, 2007 4:49 pm
Posts: 1
Table A
column id_A (primary key)
column comp_ref_x
column comp_ref_Y



Table B
column id_B (pimary key)
column colX
column colY


Table logically links to table B via composite columns comp_ref_x and comp_ref_b.

Normally this is quite simple to map in hibernate using the

<many-to-one>
<column>
<column>
</many-to-one>

element if table B's key was a composite key

But in this case it is not a composite key (it has it' down unique ID, id_B).

Is there anyway in hibernate I could use the <many-to-one> clause in conjuction with the columns comp_ref_x, comp_ref_y to reference the row back in table B.

Thanks Bill


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 25, 2007 7:02 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
B's mapping:
Code:
<many-to-one property-ref="xycomp">
  <column name="x" column="colX"/>
  <column name="y" column="colY"/>
</many-to-one>


A's mapping:
Code:
<properties name="xycomp">
  <property name="x" column="comp_ref_x"/>
  <property name="x" column="comp_ref_Y"/>
</properties>

_________________
Code tags are your friend. Know them and use them.


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.