Exception in <set>’s <one-to-many> unidirectional mapping
Parent class mapping
====================
<id name="Id" column="ID"/>
<component name="childcomponent" >
<set name="value" lazy="false" cascade="save-update" >
<key column="parent_id" not-null="true" />
<one-to-many class="Child" not-found="ignore" entity-name="childentityname" />
</set>
</component>
...
</class>
Child class mapping
===================
<class name="Child" table="ChildTable" entity-name=" childentityname">
<composite-id name="childId" >
<key-property name="value" column=" childId" />
</composite-id>
<property name="parentid" column=" parentid" insert="false" update="false"/>
...
</class>
Parent table structure
======================
Id number (pk)
Parent_name varchar2(50);
Other cols….
Child table structure
=====================
Childid number (pk)
Parented number (fk to Parent table)
Other cols….
Database
========
DB2
Hibernate
=========
Version 3.0
When I tried to save the parent object(insert), Hibernate is trying to update the child table by preparing an Update statement. My requirement is to save all the Child objects present in set by preparing insert statements.
Can any body suggest me how to map the Child object correctly?
Throwing an exception by stack trace as follows.
org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not insert collection: [com.mci.etms.eb.dataobjects.EbTicket.com.mci.etms.eb.dataobjects.EbTicket.ALocationAccessHours.value#1997]; DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: XWEEKMK1;0000000201; nested exception is com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: XWEEKMK1;0000000201
com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -803, SQLSTATE: 23505, SQLERRMC: XWEEKMK1;0000000201
|