Hi,
I am new to hibernate and have a below requirement:
I have an object of ProductJSPBean mapped to a different table in DealJSPBean object.
Everytime I save DealJSPBean which has the same primary key and holds a reference to ProductJSPBean in trade_id column which is an autogenerated key, it alwyas inserts a new row in eb_product_data.
As a result, I end up having multiple entries everytime I save DealJSPBean object.
I have tried to find the answer through various blogs and forums but nothing seems to work for me. I am stuck now.
Any kind of help, will be appreciated.
My DealJSPBean.hbm.xml looks like below:
<hibernate-mapping package="com.jpmorgan.eragbat.eblotter.jsp">
<class name="DealJSPBean" table="eb_deal_data"> <id name="dealId" column="id"> <generator class="assigned" /> </id> <property name="appropriateness" column="appness" /> <property name="lastModifiedDate" column="last_modified_date" type="date" /> <many-to-one name="productJSPBean" class="ProductJSPBean" column="trade_id" not-null="true" cascade="save-update,delete" unique="true" /> </class> <!-- ProductJSPBean.hbm.xml --> <class abstract="true" name="ProductJSPBean" table="eb_product_data"> <id name="id" column="trade_id"> <generator class="identity" /> </id> <property name="swapswireEligible" column="is_swapswire_eligible" /> <property name="mkNetINPV" column="gross_inpv" /> </class> </hibernate-mapping>
|