These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Update before delete in relation one-to-many
PostPosted: Fri May 13, 2005 5:03 am 
Newbie

Joined: Fri Mar 11, 2005 9:08 am
Posts: 4
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 .


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.