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
|