-->
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: StaleObjectStateException (Row was updated or deleted by...)
PostPosted: Mon Oct 12, 2009 8:30 am 
Newbie

Joined: Mon Dec 25, 2006 4:59 am
Posts: 15
Hi Guys


I ran into HibernateOptimisticLockingFailureException exception when trying to save task entity, which has a manny to one association to user entity, while running a Junit tests.
I am experiencing no errors while saving user entity seperatly or when associated to other entities.

This is the mapping class of task object

Code:
<hibernate-mapping package="com.something.domain.task"
   default-access="field">
   <class name="ReportTask" table="TASK" dynamic-insert="true">
      <cache usage="read-write" />
      <id name="id" column="ID" />
      <property name="updateDate" column="UPDATEDDATE" type="timestamp" />
      <many-to-one name="updatedBy" class="com.something.domain.user.User" column="UPDATEDBY"
         cascade="save-update"/>
   </class>      
</hibernate-mapping>


and here is the stack of optimistic locking exception
Code:
org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Object of class [com.something.domain.user.User] with identifier [asc344334433443]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.something.domain.user.User#asc344334433443]
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.something.domain.user.User#asc344334433443]
   at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1635)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2208)
   at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
   at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:91)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
   at org.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:801)
   at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:362)
   at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:799)
   at org.springframework.orm.hibernate3.HibernateTemplate$$FastClassByCGLIB$$cf0d264a.invoke(<generated>)
   at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
   at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:714)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:162)
   at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:53)
   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)
   at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:652)
   at com.something.common.hibernate.HibernateTemplateWithExceptionConversion$$EnhancerByCGLIB$$82993685.flush(<generated>)
   at com.something.common.hibernate.AbstractHibernateDao.flush(AbstractHibernateDao.java:183)
   at com.something.domain.task.taskRepositoryTest.testSaveTask(taskRepositoryTest.java:51)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
   at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


and one more thing i am using hibernate 3.1.3

thx


Top
 Profile  
 
 Post subject: Re: StaleObjectStateException (Row was updated or deleted by...)
PostPosted: Mon Oct 12, 2009 10:52 am 
Newbie

Joined: Mon Dec 25, 2006 4:59 am
Posts: 15
I have resolved it by removing cascade="save-update".
Which is really the case, since i don't need to cascades save and update actions from the parent to the child.


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.