-->
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: Upgrading Spring to Version 2.5.6: Hibernate StaleObjectStat
PostPosted: Fri Apr 03, 2009 1:19 pm 
Newbie

Joined: Fri Apr 03, 2009 1:17 pm
Posts: 2
We have an application in production using Spring 2.0 and Hibernate 3.24 and Oracle 10g. We are attempting to upgrade to Spring 2.5.6. When testing the upgrade, we are consistently encountering StaleObjectStateException when updating a Hibernate-persisted Order object with a many-to-one association with a Subscription object (mapping excerpts and exception stack trace below). The Java code and Hibernate mappings have not been touched for quite some time. It is clear that an UPDATE subscription SET .. WHERE subscription_id = ? and updated_date = ? statement is being executed as a result of a session.update(order) since cascade is set to “save-update”. It is also clear that that statement is modifying zero rows (according to Oracle) resulting in the StaleObjectStateException. What I don't know is: Why? I can reproduce this behavior locally with no possibility of a concurrent modification. Even more puzzling, why is this happening as the result of a Spring upgrade? I've spent all week on this problem. Any insight is most welcome.

Code:
<hibernate-mapping>
   <class name="Subscription" table="SUBSCRIPTION">
      ...
      <timestamp name="updatedDate" column="UPDATED_DATE"/>
      ...
   </class>

</hibernate-mapping>



Code:
<hibernate-mapping default-cascade="none" auto-import="false">
   <class name="Order" table="ORDER">
      ...
      <many-to-one name="subscription" cascade="save-update"
      class="Subscription" column="SUBSCRIPTION_ID" outer-join="false"
      not-null="false"/>
      ...
   </class>
</hibernate-mapping>


Code:
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [dumas.app.subscription.Subscription#2971056]
   at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1714)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2357)
   at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2257)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2557)
   at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
   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:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 03, 2009 4:30 pm 
Newbie

Joined: Fri Apr 03, 2009 4:07 pm
Posts: 2
Quote:
Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [dumas.app.subscription.Subscription#2971056]


This doesn't look lie a spring upgrade problem. The key here is that lookup your database table mapped to Subscription class for primary key = 2971056 (See, the error message gives you this info: Subscription#2971056) and verify if the data in there is actually what you tried to save or update and if any other process is operating on the same data.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 12:51 pm 
Newbie

Joined: Fri Apr 03, 2009 1:17 pm
Posts: 2
This is a Spring Upgrade problem. No Hibernate code was modified!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 06, 2009 2:05 pm 
Newbie

Joined: Fri Apr 03, 2009 4:07 pm
Posts: 2
I agree that hibernate code is not touched still this error has occurred, but why would spring interfere with hibernate mechanisms.. See if my second suggestion (looking for primary key) works for you.


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.