-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to get rid of this StaleObjectException??? Plz Help
PostPosted: Thu Aug 26, 2004 11:16 am 
Beginner
Beginner

Joined: Wed Jul 21, 2004 7:48 am
Posts: 21
Hibernate version:2.1.2

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

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 30, 2004 5:10 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
Remove the timestamp from your mapping... unless you clearly understand its purpose and how to use it...

Hint: http://www.hibernate.org/hib_docs/reference/en/html_single/#mapping-declaration-timestamp and http://www.hibernate.org/hib_docs/reference/en/html_single/#transactions-optimistic


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.