-->
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: hibernate - timestamp versioning
PostPosted: Tue Aug 15, 2006 8:15 am 
Newbie

Joined: Mon Aug 14, 2006 3:51 pm
Posts: 2
Hibernate version: 3.1

Mapping documents:
using this works:
<hibernate-mapping package="packagename.valueholder">
<class name="Gender" table="GENDER" optimistic-lock="version">
<id name="id" type="java.lang.String">
<column name="ID" precision="10" scale="0" />
<generator class="sequence">
<param name="sequence">gender_seq</param>
</generator>
</id>
<version name="version" column="VERSION" type="int"/>

but not this:
<hibernate-mapping package="packagename.valueholder">
<class name="Gender" table="GENDER" optimistic-lock="version">
<id name="id" type="java.lang.String">
<column name="ID" precision="10" scale="0" />
<generator class="sequence">
<param name="sequence">gender_seq</param>
</generator>
</id>
<version name="lastupdated" column="LASTUPDATED" type="Timestamp"/>




Full stack trace of any exception that occurs:

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [data.Gender#<null>]
at org.hibernate.event.def.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:218)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:102)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:54)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:539)


Name and version of the database you are using: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0

Problem description: When configuring the hbm.xml for our tables -
if we specify version type is int then the table update does not generate an exception/ if we specify version type is timestamp then we get the StaleObjectStateException.



Thanks for any suggestions! Diane


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.