-->
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: Mapping a composite (natural) primary key
PostPosted: Wed Mar 01, 2006 10:29 am 
Newbie

Joined: Tue Feb 28, 2006 5:03 pm
Posts: 15
Location: North Carolina
I have 2 tables that have identical composite keys. The 2 tables are mapped to domain objects and they both work as expected when treated individually. I would like (for convenience) to map them in a one-to-one relationship but I am having difficulty referencing the other's key using the property-ref.

Here are my mappings:

[code]<hibernate-mapping>
<class name="ownit.value.Reconciliation" table="Reconciliation" dynamic-insert="true" dynamic-update="true">

<composite-id name="loanKey" class="ownit.value.LoanKey" access="property">
<key-property name="loanNumber" column="gen_loan" type="java.lang.String"/>
<key-property name="settleDate" column="orig_settle_date" type="java.sql.Timestamp"/>
</composite-id>
</class>
</hibernate-mapping>

<hibernate-mapping>
<class name="ownit.value.Funding" table="Funding" dynamic-insert="true" dynamic-update="true">

<composite-id name="loanKey" class="ownit.value.LoanKey" access="property">
<key-property name="loanNumber" column="gen_loan" type="java.lang.String"/>
<key-property name="settleDate" column="orig_settle_date" type="java.sql.Timestamp"/>
</composite-id>

[b]<one-to-one name="recon" class="ownit.value.Reconciliation" property-ref="loanKey"/>[/b]

</class>
</hibernate[/code]


When I initialize hibernate and it loads the Funding mapping I get a MappingException: [b]property-ref not found: loanKeyin entity: ownit.value.Reconciliation[/b]

What is the appropriate way to map this relationship?


Top
 Profile  
 
 Post subject: one-to-one joined by id
PostPosted: Wed Mar 01, 2006 1:51 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Perhaps you do not need to use property-ref

<one-to-one name="recon" class="ownit.value.Reconciliation" constrained="true" />

http://www.hibernate.org/hib_docs/v3/re ... tional-121

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.