We have plenty of code that checks EntityEntry.getStatus() == DELETED, but with the unloaded delete optimization we don’t create entity entries anymore. Since PersistenceContext contains deletedUnloadedEntityKeys though, we could still make this work but have to review all code paths that try to handle re-saving. Imagine a model like this
When doing the following
previous Hibernate versions forced a flush due to the re-saving. Current Hibernate doesn’t do that, because there is no entity entry with status DELETED anymore that would lead to this code. The entry is missing because the remove operation used the optimized unloaded deletion. The effect of this is, that the unique key constraint for EntityHolder#sub will now start to produce constraint violation exceptions. |