I have two tables which has one to many relationship. My problem in mapping these two table is the relationship between these two table is not based on the primary key column.
For eg:
Table1: TABLE-A
Table2: TABLE-B
TABLE-A contains two columns say ACOLUMN1 ACOLUMN2 which combines to form unique in this table.
TABLE-B has the same reference of ACOLUMN1,ACOLUMN2 as AC1,AC2 which is not uinique so as to form the one-to-many relationship. how should i map in hbm.
I tried like the following
TABLE-A
----------
Code:
<properties name="comp_id">
<property name="aCol1" column="ACOLUMN1" />
<property name="aCol2" column="ACOLUMN2" />
</properties>
<set>
<key property-ref="comp_id">
<column name="AC1" />
<column name="AC2" />
</key>
</set>
TABLE-B
----------
Code:
<property name="ac1" column="AC1">
<property name="ac2" column="AC2">
but this throws the following error
Code:
org.hibernate.MappingException: collection foreign key mapping has wrong number of columns: com.mypackage.myclass type: component[aCol1,aCol2]
is something wrong in this???