The new transient-checks for deleted entities introduced with 6.6.0 are pretty useful because they surfaces implementation glitches. However, it raises false errors when entities are remove with a bulk deletion. For example, deleting entities with
em.createQuery("DELETE FROM Deployment d WHERE d.m_scope =: scopeId")
.setParameter(":scopeId", scopeId)
.executeUpdate();
will raise a wrong TransientObjectException later on that claims that one of the deleted Deployment
s is referencing another deleted (and hence transient) entity. However, using
em.createQuery("SELECT d FROM Deployment d WHERE d.m_scope = :scopeId")
.setParameter(":scopeId", scopeId)
.getResultStream()
.forEach(em::remove);
i.e. an explicit remove
works as expected without raising an exception.