org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ...

Hibernate JIRA | Andreas Benneke | 1 year ago
  1. 0

    When you initialize the collection of an OneToMany relation with {{orphanRemoval=true}} with {{null}}, Hibernate fails to persist changes to a (re)loaded entity with the following exception: {code} org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ... at org.hibernate.engine.internal.Collections.processDereferencedCollection(Collections.java:114) at org.hibernate.engine.internal.Collections.processUnreachableCollection(Collections.java:67) at org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:258) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:103) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335) {code} Things work however, if * the collection is initialized with an empty collection (instead of {{null}}) * orphanRemoval is set to false This may be related to HHH-7726 and/or HHH-9935, but the null collection case is not covered there. You may find a small stripped down test project on Github https://github.com/abenneke/sandbox/tree/master/hibernate-null-collection Thank you!

    Hibernate JIRA | 1 year ago | Andreas Benneke
    org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ...
  2. 0

    When you initialize the collection of an OneToMany relation with {{orphanRemoval=true}} with {{null}}, Hibernate fails to persist changes to a (re)loaded entity with the following exception: {code} org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ... at org.hibernate.engine.internal.Collections.processDereferencedCollection(Collections.java:114) at org.hibernate.engine.internal.Collections.processUnreachableCollection(Collections.java:67) at org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:258) at org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:103) at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335) {code} Things work however, if * the collection is initialized with an empty collection (instead of {{null}}) * orphanRemoval is set to false This may be related to HHH-7726 and/or HHH-9935, but the null collection case is not covered there. You may find a small stripped down test project on Github https://github.com/abenneke/sandbox/tree/master/hibernate-null-collection Thank you!

    Hibernate JIRA | 1 year ago | Andreas Benneke
    org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ...
  3. 0

    Hibernate exceptions while executing jobs

    https://bugzilla.redhat.com/bugzilla/ | 1 year ago | Israel Pinto
    javax.persistence.PersistenceException: org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: org.ovirt.engine.core.common.job.Job.steps
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Fallo en valores calculados al cambiar referencia

    openxava | 5 months ago | pespadas
    javax.persistence.PersistenceException: org.hibernate.HibernateException: identifier of an instance of org.navigo.gena3.modelo.Articulo was altered from 1 to 2
  6. 0

    hibernate error Don't change the reference to a collection with cascade="all-delete-orphan" on flush

    Stack Overflow | 2 years ago | user3090074
    org.hibernate.HibernateException: Don't change the reference to a collection with cascade="all-delete-orphan": com.ipc.callcenter.orm.ContractWithManagementCompanyDocumentModel.buildings

    2 unregistered visitors
    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.HibernateException

      A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance: ...

      at org.hibernate.engine.internal.Collections.processDereferencedCollection()
    2. Hibernate
      SessionImpl.flush
      1. org.hibernate.engine.internal.Collections.processDereferencedCollection(Collections.java:114)
      2. org.hibernate.engine.internal.Collections.processUnreachableCollection(Collections.java:67)
      3. org.hibernate.event.internal.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:258)
      4. org.hibernate.event.internal.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:103)
      5. org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:55)
      6. org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1258)
      6 frames
    3. org.hibernate.jpa
      AbstractEntityManagerImpl.flush
      1. org.hibernate.jpa.spi.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:1335)
      1 frame