-->
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.  [ 4 posts ] 
Author Message
 Post subject: I get StaleObjectException when trying to update...
PostPosted: Fri Aug 27, 2004 2:18 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 7:48 am
Posts: 21
Hi all,
I am getting StaleObjectException when I try to update a row.


Mapping documents:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class
name="com.systec.lifetec.labs.valueobjects.ResultCodeVO"
table="tbl_test_result_code"
dynamic-update="false"
dynamic-insert="false"
>

<id
name="resultCode"
column="result_code"
type="java.lang.String"
>
<generator class="assigned">
</generator>
</id>

<timestamp
name="updateDateTime"
column="updt_datetime"
/>

<property
name="description"
type="java.lang.String"
update="true"
insert="true"
column="description"
/>

<property
name="active"
type="boolean"
update="true"
insert="true"
column="active"
/>

<property
name="showInLegend"
type="boolean"
update="true"
insert="true"
column="show_in_legend"
/>

<property
name="userID"
type="java.lang.String"
update="true"
insert="true"
column="updt_userid"
not-null="true"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-ResultCodeVO.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>




Code between sessionFactory.openSession() and session.close():

Session ss=openSession();
Transaction tr=ss.beginTransaction();
ss.update(resultCodeVO)
tr.commit();
ss.close();
[PS-resultCodeVO is an object of ResultCodeVO class]



Full stack trace of any exception that occurs:

Hibernate: update tbl_test_result_code set updt_datetime=?, description=?, activ
e=?, show_in_legend=?, updt_userid=? where result_code=? and updt_datetime=?
net.sf.hibernate.StaleObjectStateException.<init>(StaleObjectStateException.java
:27) -- An operation failed due to stale data
net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by anothe
r transaction (or unsaved-value mapping was incorrect) for com.systec.lifetec.la
bs.valueobjects.ResultCodeVO instance with identifier: QW



Name and version of the database you are using: SQL Server 2000


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 2:21 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
Quote:
Row was updated or deleted by anothe
r transaction (or unsaved-value mapping was incorrect)


have you ruled out both of those possibilities described?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 7:24 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 7:48 am
Posts: 21
tq wrote:
Quote:
Row was updated or deleted by anothe
r transaction (or unsaved-value mapping was incorrect)


have you ruled out both of those possibilities described?



The first condition I hav ruled out. About the second even when I give the XDoclet tag @hibernate.timestamp unsaved-value="undefined".This is not being shown in mapping file as u can see.I am using XDoclet 1.2 and ant to generate the mapping files. I think the second condition is probably causing the session to contain stale data.Plz let me know how to get that unsaved-value="undefined" in the mapping file through XDoclet and ant.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 27, 2004 7:42 am 
Regular
Regular

Joined: Thu Aug 05, 2004 2:27 am
Posts: 54
Location: South Africa
mithunk wrote:
The first condition I hav ruled out. About the second even when I give the XDoclet tag @hibernate.timestamp unsaved-value="undefined".This is not being shown in mapping file as u can see.I am using XDoclet 1.2 and ant to generate the mapping files. I think the second condition is probably causing the session to contain stale data.Plz let me know how to get that unsaved-value="undefined" in the mapping file through XDoclet and ant.


I actually write the mapping files and generate the pojo's, never used x-doclet for hibernate.
but try pasting unsaved-value="undefined" into the mapping to confirm that is the problem.

also, I don't know how relevant this is, but I saw a blog that may be related to your problem...
Quote:
@hibernate.version Current release of xdoclet-hibernate-module does not not extract the unsaved-value and access correclty! You have build it
Quote:
form cvs direclty if you you need these attributes for your mapping. (2004-07-15 09:40:22.0) Permalink Comments [0]


copied from http://www.jroller.com/page/tradem/20040715


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

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.