javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1]

Hibernate JIRA | Chris Watts | 3 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    [HHH-8786] EntityManager.find() throws PersistenceException when a lock cannot be obtained - Hibernate JIRA

    atlassian.net | 2 years ago
    javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1]
  2. 0

    When calling: NOWAIT.put("javax.persistence.lock.timeout", 0L); entityManager.refresh(entity, LockModeType.PESSIMISTIC_WRITE, NOWAIT); PersistenceException is thrown. A LockTimeoutException should be thrown, the same as EntityManager.lock throws. {noformat} Failed to achieve lock on entity: VersionedItem [id=1, name=one]. Reason: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1] javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387) at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:949) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:366) at com.sun.proxy.$Proxy20.refresh(Unknown Source) at org.apache.camel.component.jpa.JpaConsumer.lockEntity(JpaConsumer.java:315) at org.apache.camel.component.jpa.JpaConsumer.processBatch(JpaConsumer.java:171) at org.apache.camel.component.jpa.JpaConsumer$1.doInTransaction(JpaConsumer.java:118) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131) at org.apache.camel.component.jpa.JpaConsumer.poll(JpaConsumer.java:94) Caused by: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1] at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:94) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.loader.Loader.loadEntity(Loader.java:2125) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3927) at org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:144) at org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:63) at org.hibernate.internal.SessionImpl.fireRefresh(SessionImpl.java:1138) at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1127) at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1123) at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:939) {noformat}

    Hibernate JIRA | 3 years ago | Chris Watts
    javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1]
  3. 0

    When calling: NOWAIT.put("javax.persistence.lock.timeout", 0L); entityManager.refresh(entity, LockModeType.PESSIMISTIC_WRITE, NOWAIT); PersistenceException is thrown. A LockTimeoutException should be thrown, the same as EntityManager.lock throws. {noformat} Failed to achieve lock on entity: VersionedItem [id=1, name=one]. Reason: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1] javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1] at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1387) at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:949) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:366) at com.sun.proxy.$Proxy20.refresh(Unknown Source) at org.apache.camel.component.jpa.JpaConsumer.lockEntity(JpaConsumer.java:315) at org.apache.camel.component.jpa.JpaConsumer.processBatch(JpaConsumer.java:171) at org.apache.camel.component.jpa.JpaConsumer$1.doInTransaction(JpaConsumer.java:118) at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:131) at org.apache.camel.component.jpa.JpaConsumer.poll(JpaConsumer.java:94) Caused by: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1] at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:94) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.loader.Loader.loadEntity(Loader.java:2125) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3927) at org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:144) at org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:63) at org.hibernate.internal.SessionImpl.fireRefresh(SessionImpl.java:1138) at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1127) at org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1123) at org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:939) {noformat}

    Hibernate JIRA | 3 years ago | Chris Watts
    javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: could not load an entity: [org.apache.camel.examples.VersionedItem#1]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.exception.LockAcquisitionException

      could not load an entity: [org.apache.camel.examples.VersionedItem#1]

      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert()
    2. Hibernate
      SessionImpl.refresh
      1. org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:94)
      2. org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
      3. org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
      4. org.hibernate.loader.Loader.loadEntity(Loader.java:2125)
      5. org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
      6. org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
      7. org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3927)
      8. org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:144)
      9. org.hibernate.event.internal.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:63)
      10. org.hibernate.internal.SessionImpl.fireRefresh(SessionImpl.java:1138)
      11. org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1127)
      12. org.hibernate.internal.SessionImpl.refresh(SessionImpl.java:1123)
      12 frames
    3. Hibernate EJB
      AbstractEntityManagerImpl.refresh
      1. org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:939)
      1 frame