From 00492a3707b9128b34646166f6eff402a8169011 Mon Sep 17 00:00:00 2001 From: Chris Cranford Date: Fri, 29 Sep 2017 16:47:14 -0400 Subject: [PATCH] HHH-11965 - Fix cascade of one-to-one associations with proxies. --- .../main/java/org/hibernate/engine/internal/Cascade.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java index 71bd4a1118..10d069c671 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java @@ -285,6 +285,15 @@ public final class Cascade { // useful for @OneToOne defined as FetchType.LAZY loadedValue = eventSource.getPersistenceContext().unproxyAndReassociate( loadedValue ); valueEntry = eventSource.getPersistenceContext().getEntry( loadedValue ); + + // HHH-11965 + // Should the unwrapped proxy value be equal via reference to the entity's property value + // provided by the 'child' variable, we should not trigger the orphan removal of the + // associated one-to-one. + if ( child == loadedValue ) { + // do nothing + return; + } } if ( valueEntry != null ) {