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.  [ 3 posts ] 
Author Message
 Post subject: One-To-One with more then one keyfield
PostPosted: Thu Jun 19, 2008 10:25 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
I have successful define a one-to-one mapping when one keyfield is used. for example:
Table address with field adrno
Table addressaddition with field adrno 1:1 to address.adrno

<class name="Address" table="vkunadr">
<id name="AdrNo" access="field.pascalcase-underscore" column="adrno">
<generator class="assigned" />
</id>
<one-to-one cascade="all" name="AddressAddition" class="AddressAddition" access="field.pascalcase-underscore"/>
</class>
</hibernate-mapping>

<class name="AddressAddition" table="vkunzus">
<id name="AdrNo" column="adrno" access="field.pascalcase-underscore">
<generator class="foreign">
<param name="property">Address</param>
</generator>
</id>
<one-to-one name="Address" class="Address" access="field.pascalcase-underscore"/>
</class>

But my problem is to define a one-to-one mapping for 2 fields. Example
Table1, Field f1 + Field f2
Table2, Field f1 + Field f2, 1:1 to the 2 fields of Table1

How can i define this mapping?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 19, 2008 10:32 am 
Regular
Regular

Joined: Thu Mar 06, 2008 5:06 am
Posts: 68
I think, that is not possible. Use a many-to-one instead and set the unique attribute:

Code:
    <many-to-one name="Address" class="Address" unique="true">
      <column name="COL1" />
      <column name="COL2" />
    </many-to-one>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 2:51 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
Thank you very much! This works fine!


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