From e1b08967d947f12ee774ebbbc5b9e1a38a360603 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Thu, 24 May 2018 23:56:26 -0700 Subject: [PATCH] Revert "HHH-12592 - Fix merging detached enhanced entities with orphan-removal collections." This reverts commit 4f119105f887855d6baecb0ac8837d984b40b4b7. --- .../java/org/hibernate/type/CollectionType.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java index 4f1e709cb1..428c7bbb08 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java @@ -689,15 +689,10 @@ public abstract class CollectionType extends AbstractType implements Association // for a null target, or a target which is the same as the original, we // need to put the merged elements in a new collection - Object result; - if ( target == LazyPropertyInitializer.UNFETCHED_PROPERTY ) { - result = original; - } - else { - result = ( target == null || target == original ) ? - instantiateResult( original ) : - target; - } + Object result = ( target == null || + target == original || + target == LazyPropertyInitializer.UNFETCHED_PROPERTY ) ? + instantiateResult( original ) : target; //for arrays, replaceElements() may return a different reference, since //the array length might not match