From 04ce594959c222885bc161297293b5f6a3b26672 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Tue, 28 Feb 2023 10:12:02 +0100 Subject: [PATCH] HHH-16209 Identically-named association in entity root and embeddable leads to mixup during association loading --- .../metamodel/mapping/internal/ToOneAttributeMapping.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java index 838e6d449d..b19ef3ee6a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java @@ -1068,7 +1068,10 @@ public class ToOneAttributeMapping NavigablePath navigablePath = parentNavigablePath.trimSuffix( bidirectionalAttributePath ); if ( navigablePath != null ) { - if ( navigablePath.getLocalName().equals( EntityIdentifierMapping.ROLE_LOCAL_NAME ) ) { + final String localName = navigablePath.getLocalName(); + if ( localName.equals( EntityIdentifierMapping.ROLE_LOCAL_NAME ) + || localName.equals( ForeignKeyDescriptor.PART_NAME ) + || localName.equals( ForeignKeyDescriptor.TARGET_PART_NAME ) ) { navigablePath = navigablePath.getParent(); } return creationState.resolveModelPart( navigablePath ).getPartMappingType() == entityMappingType;