From bea9d12115a88234150f9d461891026b6d568d82 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Wed, 6 Sep 2023 11:10:10 +0200 Subject: [PATCH] HHH-17156 Skip initialization for different subtype embeddables --- .../graph/embeddable/AbstractEmbeddableInitializer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java index b1ee699fcc..77c4fd0ecb 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java @@ -267,6 +267,10 @@ public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentA // parent instance is null; return State.NULL; } + else if ( !entityInitializer.getConcreteDescriptor().isTypeOrSuperType( embedded.findContainingEntityMapping() ) ) { + // parent instance is of a supertype which doesn't contain this embeddable + return State.NULL; + } else if ( entityInitializer.isEntityInitialized() ) { // parent instance has been initialized, we do not need to inject the state return State.INJECTED;