I have two tables Order and OrderAlloc
Order
====
Order_Id (PK)
Trade_Date (PK) <=========
xxxxx
OrderAlloc
=======
Alloc_Id (PK)
Trade_Date (PK) and (FK) <=========
Order_Id (FK)
xxxxxx
Here's the mapping file for OrderAlloc:
<composite-id name="id" class="OrderAllocsIdVO">
<key-property name="allocId" type="string">
<column name="ALLOC_ID" length="15" />
</key-property>
<key-property name="tradeDate" type="date">
<column name="TRADE_DATE" length="7" not-null="true" />
</key-property>
</composite-id>
<version
name="version"
column="version"
type="long"
/>
<many-to-one name="FXOrder" class="OrderVO"
fetch="select" insert="true" update="true">
<column name="ORDER_ID" length="15" not-null="true" />
<column name="TRADE_DATE" length="7" not-null="true" />
</many-to-one>
The problem is that
1. if insert="true" update="true", it complaints with with repeating columns
2. if insert="false" update="false", will insert null value of Order_Id on Table Order_alloc. It's expected as Order_Id won't be included on the insert/update statement.
Therefore, how to solve this on Hibernate?
Thanks!
|