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.  [ 1 post ] 
Author Message
 Post subject: one-to-many mapping with different field names – Persisten
PostPosted: Mon Jul 23, 2007 3:44 pm 
Newbie

Joined: Mon Jul 23, 2007 3:04 pm
Posts: 1
I'm working with persistent XML data rather then POJOs and trying to figure out how to get one-to-many mapping working when field names are different, in Table_1 its PERSON_ID and in Table_2 it's PER_PERSON_ID. DB is Oracle 8i.

Table_1
---------
PERSON_ID
LName
MNAME
FNAME

Table_2
---------
Addr_ID
PER_PERSON_ID
Address_1
Address_2

This is what I have and it worked for me in all the cases where field names match:

MasterNames:
<hibernate-mapping>
<class entity-name="MasterNames" node="row" schema="DBA" table="Table_1">
<id name="mstr" column="PERSON_ID" node="PersonID" type="string" length="13"/>
<set name="RelatedIncidents" node="Addrs">
<key column="PERSON_ID" not-null="true" update="false"/>
<one-to-many entity-name="Addresses"/>
</set>
</class>
</hibernate-mapping>

Addresses
<hibernate-mapping>
<class entity-name="Addresses" schema="DBA" table="Table_2" node="AddressNode" mutable="false">
<id name="PerID" column="Addr_ID" type="string" node="AddrID"/>
<property name="perID" column="PER_PERSON_ID" type="string" node="perID"/>
<property name="Addr" column="Address_1" type="string" node="Addr"/>
</class>
</hibernate-mapping>

I always get "field not found" error, as I should, since PERSON_ID doesn’t exist in Table_2.
Thank you in advance for your help.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.