2 Replies Latest reply: Oct 8, 2011 2:03 PM by Johan Sintorn RSS

    Entity with @OptimisticLocking(type=OptimisticLockType.ALL) and find with actually LockModeType=OPTIMISTIC

    Johan Sintorn Newbie

      Does anybody know if @OptimisticLocking(type=OptimisticLockType.ALL) works at all?

       

      Tried in AS7.0.1 and in AS6.1.0 with bundled Hibernate versions ( 4.0.0.Beta4 resp 3.6.6), but as soon as entities are looked up by find(class,key,LockModeType.OPTIMISTIC) Hibernate will crash on null pointer exception during commit. Stack trace is (in AS 6.1.0)

       

      22:49:18,924 ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): java.lang.NullPointerException

          at org.hibernate.action.EntityVerifyVersionProcess.doBeforeTransactionCompletion(EntityVerifyVersionProcess.java:56) [:3.6.6.Final]

          at org.hibernate.engine.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:543) [:3.6.6.Final]

          at org.hibernate.engine.ActionQueue.beforeTransactionCompletion(ActionQueue.java:216) [:3.6.6.Final]

          at org.hibernate.impl.SessionImpl.beforeTransactionCompletion(SessionImpl.java:571) [:3.6.6.Final]

          at org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:250) [:3.6.6.Final]

          at org.hibernate.transaction.synchronization.CallbackCoordinator.beforeCompletion(CallbackCoordinator.java:125) [:3.6.6.Final]

          at org.hibernate.transaction.synchronization.HibernateSynchronizationImpl.beforeCompletion(HibernateSynchronizationImpl.java:51) [:3.6.6.Final]

          at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:97) [:6.1.0.Final]

          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:274) [:6.1.0.Final]

          at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:94) [:6.1.0.Final]

          at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:159) [:6.1.0.Final]

          at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1158) [:6.1.0.Final]

          at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:119) [:6.1.0.Final]

          at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75) [:6.1.0.Final]

          at org.jboss.tm.usertx.client.ServerVMClientUserTransaction.commit(ServerVMClientUserTransaction.java:162) [:6.1.0.Final]

       

      Should mention that transaction is bean-managed and dbms is MySQL 5.1. When not setting LockModeType.OPTIMISTIC it sort of works, but then there is no concurrency check and inconsistent transactions are let through, overwriting each other.

       

      Anybody found any way at all to use optimistic concurrency control without @version columns in DB? Thanks for your help