org.springframework.orm.ObjectOptimisticLockingFailureException: Object of class [Instance] with identifier [a5deddb9-d76c-433f-8b0d-e50cbf8f601e]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) :

Stack Overflow | Derek | 5 months ago
  1. 0

    optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException when persisting a record with Spring Data's CrudRepository

    Stack Overflow | 5 months ago | Derek
    org.springframework.orm.ObjectOptimisticLockingFailureException: Object of class [Instance] with identifier [a5deddb9-d76c-433f-8b0d-e50cbf8f601e]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) :

    Root Cause Analysis

    1. org.springframework.orm.ObjectOptimisticLockingFailureException

      Object of class [Instance] with identifier [a5deddb9-d76c-433f-8b0d-e50cbf8f601e]: optimistic locking failed; nested exception is org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) :

      at org.hibernate.persister.entity.AbstractEntityPersister.check()
    2. Hibernate
      AbstractTransactionImpl.commit
      1. org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2541)
      2. org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3285)
      3. org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3183)
      4. org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3525)
      5. org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:159)
      6. org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:465)
      7. org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:351)
      8. org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350)
      9. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56)
      10. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
      11. org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425)
      12. org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
      13. org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177)
      13 frames
    3. org.hibernate.jpa
      TransactionImpl.commit
      1. org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:77)
      1 frame
    4. Spring ORM
      JpaTransactionManager.doCommit
      1. org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:517)
      1 frame
    5. Spring Tx
      TransactionInterceptor.invoke
      1. org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:761)
      2. org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:730)
      3. org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:485)
      4. org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291)
      5. org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      5 frames
    6. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      1 frame
    7. Spring Tx
      PersistenceExceptionTranslationInterceptor.invoke
      1. org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
      1 frame
    8. Spring AOP
      ReflectiveMethodInvocation.proceed
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      1 frame
    9. Spring Data JPA
      CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke
      1. org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:131)
      1 frame
    10. Spring AOP
      JdkDynamicAopProxy.invoke
      1. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      2. org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
      3. org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      4. org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:208)
      4 frames
    11. com.sun.proxy
      $Proxy139.save
      1. com.sun.proxy.$Proxy139.save(Unknown Source)
      1 frame