HHH-18289 with leads to HibernateException: A collection with cascade= was no longer referenced by the owning entity instance

This commit is contained in:
Andrea Boriero 2024-07-17 14:13:57 +02:00
parent 7843051f05
commit 88882cd2d8
1 changed files with 6 additions and 1 deletions

View File

@ -654,7 +654,12 @@ public abstract class CollectionType extends AbstractType implements Association
final Object owner, final Object owner,
final Map<Object, Object> copyCache) throws HibernateException { final Map<Object, Object> copyCache) throws HibernateException {
if ( original == null ) { if ( original == null ) {
return null; if ( target == null ) {
return target;
}
final Collection collection = (Collection) target;
collection.clear();
return collection;
} }
if ( !Hibernate.isInitialized( original ) ) { if ( !Hibernate.isInitialized( original ) ) {
if ( ( (PersistentCollection<?>) original ).hasQueuedOperations() ) { if ( ( (PersistentCollection<?>) original ).hasQueuedOperations() ) {