From d616f2aa5539550a667513b7e72491a91adfe7b7 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 13 Oct 2021 11:53:16 +0200 Subject: [PATCH] Fix ToOneAttributeMapping tableGroup creation --- .../ast/internal/LoaderSelectBuilder.java | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java index 5b2879f7da..f9c92d6bfa 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java @@ -415,21 +415,16 @@ public class LoaderSelectBuilder { } else if ( part instanceof ToOneAttributeMapping ) { final ToOneAttributeMapping toOneAttributeMapping = (ToOneAttributeMapping) part; - if ( toOneAttributeMapping.getSideNature() == ForeignKeyDescriptor.Nature.TARGET ) { - final TableGroupJoin tableGroupJoin = toOneAttributeMapping.createTableGroupJoin( - navigablePath, - rootTableGroup, - null, - SqlAstJoinType.LEFT, - true, - sqlAstCreationState - ); - tableGroup = tableGroupJoin.getJoinedGroup(); - sqlAstCreationState.getFromClauseAccess().registerTableGroup( navigablePath, tableGroup ); - } - else { - tableGroup = rootTableGroup; - } + final TableGroupJoin tableGroupJoin = toOneAttributeMapping.createTableGroupJoin( + navigablePath, + rootTableGroup, + null, + SqlAstJoinType.LEFT, + true, + sqlAstCreationState + ); + tableGroup = tableGroupJoin.getJoinedGroup(); + sqlAstCreationState.getFromClauseAccess().registerTableGroup( navigablePath, tableGroup ); } else { tableGroup = rootTableGroup;