-->
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: RollbackException thrown instead of OptimisitcLockException
PostPosted: Thu Mar 15, 2007 2:58 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,

I make a change to a POJO, but do not commit the change. I spawn a thread, (that uses it's own EntityManager) and which makes changes to the same POJO which it successfully commits. I then try to commit a the change in the original thread. I expect an javax.persistence.OptimisticLockException, but I get a javax.persistence.RolllbackException,

Why does Hibernate not chuck the OptimisticLockException?

Here are more details from the stack trace,

Caused by: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.fineos.ta3g.test.garage.Address#C=3001,I=1297]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1680)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2272)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2180)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2450)
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:993)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:53)
... 20 more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 15, 2007 6:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate now wrap the Stale exception into an OptimisticLockException

But remember that commit() has to wrap exceptions

@throws RollbackException if the commit fails.

so Optimistic lock exception will be wrapped ino a Rollbackexception

_________________
Emmanuel


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.