Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 3.0.2
Mapping documents:
Parnet mapping:
<hibernate-mapping >
<class name="parnet" table="parnet" dynamic-insert="true" dynamic-update="true">
<composite-id name="ID" class="ID" >
<key-property name="id" column="ID" type="integer"/>
<key-property name="stringId" column="stringId" />
</composite-id>
<timestamp name="timestamp" column="timestamp" unsaved-value="null"/>
<set name="childs" inverse="true" lazy="false" cascade="all-delete-orphan" fetch="join" >
<key >
<column name="FKID" />
<column name="FKSTringID"/>
</key>
<one-to-many class="Child" />
</set>
</class>
</hibernate-mapping >
Child mapping:
<hibernate-mapping>
<class name="Child" table="Child" dynamic-insert="true" dynamic-update="true">
<composite-id name="key" class="childKey" >
<key-many-to-one name="parnet" class="parnet" >
<column name="FKID"/>
<column name="FKStringId"/>
</key-many-to-one>
<key-many-to-one name="C" column="FKC" class="C"/>
</composite-id>
<timestamp name="timestamp" column="TIMESTAMP" unsaved-value="null"/>
<property name="Date" column="Date"/>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
delete(parnet);
Name and version of the database you are using:DB2
when delete the parnet an update in 3 statment throw
1- update parnet !! ( set new timestamp )
2- delete child
3- delete parnet
which not work and throw exception :
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): Parnet#Id
Why the update statment throw !
Is when delete the child update the parnet timestamp ..which is strange .