Table A
--------
Primary key in DB and mapping file is composite-id of LossNumber,LossDate,Currency columns.
Table B
--------
There is no primary key in DB. Mapping file has RunNumber as primary key. This table also has LossNumber,LossDate columns, but it does not have Currency columns.
The relationship from A to B is based on the first 2 columns in primary ID of Table A. For a given LossNumber,LossDate in Table A, there can be more than one record in Table B.
I am interested only in the relationship of A to B and not vice versa.
My mapping file for table A is
Code:
<class table="TableA" name="tableA">
<composite-id class=TableA" name="TableAPrimaryKey">
<key-property column="LOSS_NUMBER" type="java.lang.String" name="lossNumber"/>
<key-property column="LOSS_DATE" type="java.lang.Short" name="lossDate"/>
<key-property column="CURRENCY" type="java.lang.String" name="curCode"/>
</composite-id>
.......
.......
<set order-by="RUN_NUMBER" table="TableB" name="tableBrecords">
<key>
<column name="LOSS_NUMBER"/>
<column name="LOSS_DATE"/>
</key>
<one-to-many not-found="ignore" class="TableB"/>
</set>
</class>
Above mapping file gives me an error which says "Foreign key must have same number of columns as the referenced primary key"