org.hibernate.ObjectDeletedException: attempted to lock a deleted instance: [...]

Hibernate JIRA | Miguel Diaz | 4 years ago
  1. 0

    When an entity is read using a read-only HQL query, if you run a Session.get() for that entity with LockOptions.UPGRADE you get a ObjectDeletedException. The reason of the failure is that the EntityEntry has status READ after the HQL query, and when the lock mode is upgraded in the Session.get(), AbstractLockUpgradeEventListener thinks that the READ status is wrong, throwing the ObjectDeletedException. I think that a READ_ONLY entity should be moved to MANAGED if you lock it. Or, otherwise, advice in the docs that a READ_ONLY entity can't be locked. Stacktrace: org.hibernate.ObjectDeletedException: attempted to lock a deleted instance: [...] at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:67) at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:551) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:440) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227) at org.hibernate.event.def.DefaultLoadEventListener.lockAndLoad(DefaultLoadEventListener.java:403) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:155) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1081)

    Hibernate JIRA | 4 years ago | Miguel Diaz
    org.hibernate.ObjectDeletedException: attempted to lock a deleted instance: [...]
  2. 0

    When an entity is read using a read-only HQL query, if you run a Session.get() for that entity with LockOptions.UPGRADE you get a ObjectDeletedException. The reason of the failure is that the EntityEntry has status READ after the HQL query, and when the lock mode is upgraded in the Session.get(), AbstractLockUpgradeEventListener thinks that the READ status is wrong, throwing the ObjectDeletedException. I think that a READ_ONLY entity should be moved to MANAGED if you lock it. Or, otherwise, advice in the docs that a READ_ONLY entity can't be locked. Stacktrace: org.hibernate.ObjectDeletedException: attempted to lock a deleted instance: [...] at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:67) at org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:551) at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:440) at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227) at org.hibernate.event.def.DefaultLoadEventListener.lockAndLoad(DefaultLoadEventListener.java:403) at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:155) at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090) at org.hibernate.impl.SessionImpl.get(SessionImpl.java:1081)

    Hibernate JIRA | 4 years ago | Miguel Diaz
    org.hibernate.ObjectDeletedException: attempted to lock a deleted instance: [...]
  3. 0

    deleted entity passed to persist exception ??? | JBoss Developer

    jboss.org | 7 months ago
    org.hibernate.ObjectDeletedException: deleted entity passed to persist: [foo.bar.ProductGroup#]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    failure to add metadata: Hibernate problem with re-saving deleted object

    GitHub | 7 months ago | dewarim
    org.springframework.dao.InvalidDataAccessApiUsageException: deleted object would be re-saved by cascade (remove deleted object from associations): [cinnamon.OsdMetaset#3002]; nested exception is org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [cinnamon.OsdMetaset#3002]
  6. 0

    Extremely weird deleted object would be re-saved by cascade error

    Stack Overflow | 2 years ago | James
    org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): [com.amazon.promotions.storage.hibernate.types.Hospital#57]

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.ObjectDeletedException

      attempted to lock a deleted instance: [...]

      at org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock()
    2. Hibernate
      SessionImpl.get
      1. org.hibernate.event.def.AbstractLockUpgradeEventListener.upgradeLock(AbstractLockUpgradeEventListener.java:67)
      2. org.hibernate.event.def.DefaultLoadEventListener.loadFromSessionCache(DefaultLoadEventListener.java:551)
      3. org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:440)
      4. org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:227)
      5. org.hibernate.event.def.DefaultLoadEventListener.lockAndLoad(DefaultLoadEventListener.java:403)
      6. org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:155)
      7. org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:1090)
      8. org.hibernate.impl.SessionImpl.get(SessionImpl.java:1081)
      8 frames