Skip to content

Commit ba88d7c

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

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
@@ -638,6 +638,14 @@ public Object replace(
638638
final Object owner,
639639
final Map<Object, Object> copyCache) throws HibernateException {
640640
if ( original == null ) {
641+
if ( target == null ) {
642+
return null;
643+
}
644+
if ( target instanceof PersistentCollection ) {
645+
final Collection collection = (Collection) target;
646+
collection.clear();
647+
return collection;
648+
}
641649
return null;
642650
}
643651
if ( !Hibernate.isInitialized( original ) ) {

0 commit comments

Comments
 (0)