Skip to content

Commit 84cc5f0

Browse files
committed
HHH-18289 with leads to HibernateException: A collection with cascade= was no longer referenced by the owning entity instance
1 parent fab9834 commit 84cc5f0

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hibernate-core/src/main/java/org/hibernate/type/CollectionType.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,14 @@ public Object replace(
631631
final Object owner,
632632
final Map<Object, Object> copyCache) throws HibernateException {
633633
if ( original == null ) {
634+
if ( target == null ) {
635+
return null;
636+
}
637+
if ( target instanceof PersistentCollection ) {
638+
final Collection collection = (Collection) target;
639+
collection.clear();
640+
return collection;
641+
}
634642
return null;
635643
}
636644
if ( !Hibernate.isInitialized( original ) ) {

0 commit comments

Comments
 (0)