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 committed by Andrea Boriero
parent fab98341d3
commit 84cc5f013c
1 changed files with 8 additions and 0 deletions

View File

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