From dbf5d222bbc87b1cdc079a40247fc56ecb0a3dbc Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Tue, 13 Aug 2024 10:59:31 +0200 Subject: [PATCH] HHH-18469 Use collection element table group when resolving circular bidirectional fetch --- .../mapping/internal/ToOneAttributeMapping.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) 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 24905b5091..7b005d2d41 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 @@ -1332,14 +1332,7 @@ public class ToOneAttributeMapping // We get here is this is a lazy collection initialization for which we know the owner is in the PC // So we create a delayed fetch, as we are sure to find the entity in the PC final FromClauseAccess fromClauseAccess = creationState.getSqlAstCreationState().getFromClauseAccess(); - final NavigablePath realParent; - if ( CollectionPart.Nature.fromNameExact( parentNavigablePath.getLocalName() ) != null ) { - realParent = parentNavigablePath.getParent(); - } - else { - realParent = parentNavigablePath; - } - final TableGroup parentTableGroup = fromClauseAccess.getTableGroup( realParent ); + final TableGroup parentTableGroup = fromClauseAccess.getTableGroup( parentNavigablePath ); final DomainResult domainResult; if ( sideNature == ForeignKeyDescriptor.Nature.KEY ) { domainResult = foreignKeyDescriptor.createKeyDomainResult(