|
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.
|