-->
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: Mapping relationship between arbitrary non-key properties
PostPosted: Thu Oct 03, 2013 5:11 am 
Regular
Regular

Joined: Sat Apr 23, 2005 7:28 am
Posts: 52
I struggling to map a Set relationship between two classes where the child does not have a reference to the parent id.
In other words, I need to map a relationship using some arbitrary properties of the two tables - but HOW?
This is a legacy database where I can not make any changes to the database

Class Ot_ncr is 'parent', Pnr_notes is 'child'

Currently the (working) mapping files look like this - I have omitted a lot of the detail for the sake of clarity:

Code:
<class name="Ot_ncr" table="OT_NCR" >
        <id name="ncr_id" type="integer" >
            <column name="NCR_ID" not-null="true" />
            <generator class="assigned"/>
        </id>
        <property name="wo_no" type="string">
            <column name="WO_NO" length="10" not-null="false" />
        </property>
        <property name="op_no" type="short">
            <column name="OP_NO" not-null="false" />
        </property>
        .....
        other properties
        .....
</class>


Code:
<class name="Pnr_notes" table="PNR_NOTES">
        <composite-id>
            <key-property name="supplier_code" type="string">
                <column length="10" name="SUPPLIER_CODE" not-null="false"/>
            </key-property>
            <key-property name="wo_no" type="string">
                <column length="10" name="WO_NO" not-null="false"/>
            </key-property>
            <key-property name="op_no" type="short">
                <column name="OP_NO" not-null="false"/>
            </key-property>
            <key-property name="unique_identifier" type="double">
                <column name="UNIQUE_IDENTIFIER" not-null="false" precision="15" scale="0"/>
            </key-property>
        </composite-id>
        <property name="po_no" type="string">
            <column length="10" name="PO_NO" not-null="false"/>
        </property>
        .....
        other properties
        .....
</class>


I now need to introduce a Set (or other collection) mapping into the Class Ot_ncr; my first (not working) trial was as follows:

Code:
<class name="Ot_ncr" table="OT_NCR" >
        <id name="ncr_id" type="integer" >
            <column name="NCR_ID" not-null="true" />
            <generator class="assigned"/>
        </id>
        <property name="wo_no" type="string">
            <column name="WO_NO" length="10" not-null="false" />
        </property>
        <property name="op_no" type="short">
            <column name="OP_NO" not-null="false" />
        </property>
        .....
        other properties
        .....
        <set inverse="false" lazy="false" name="wo_pnr_notes" table="PNR_NOTES">
            <key>
                 <column name="wo_no" />
                 <column name="op_no" />
            </key>
            <one-to-many class="Pnr_notes"/>
        </set>
</class>


The thing to note is that the properties I need to map an association on 'wo_no' and 'op_no' are not full keys in either table.

I've tried a number of other ways - but so far without success - can this be done?


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.