From 00209bb82cdd6efa91c8cf28840af277ba32d315 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Mon, 25 Sep 2023 13:58:58 +0200 Subject: [PATCH] HHH-17255 Fix treated join basic path table reference resolution --- .../sqm/sql/internal/BasicValuedPathInterpretation.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java index 7dddcde85f..b8ab884ebb 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java @@ -44,10 +44,8 @@ public class BasicValuedPathInterpretation extends AbstractSqmPathInterpretat SqmBasicValuedSimplePath sqmPath, SqmToSqlAstConverter sqlAstCreationState, boolean jpaQueryComplianceEnabled) { - final FromClauseAccess fromClauseAccess = sqlAstCreationState.getFromClauseAccess(); - final TableGroup tableGroup = fromClauseAccess.getTableGroup( sqmPath.getNavigablePath().getParent() ); - final SqmPath lhs = sqmPath.getLhs(); + final TableGroup tableGroup = sqlAstCreationState.getFromClauseAccess().getTableGroup( lhs.getNavigablePath() ); EntityMappingType treatTarget = null; final ModelPartContainer modelPartContainer; if ( lhs instanceof SqmTreatedPath ) { @@ -87,7 +85,7 @@ public class BasicValuedPathInterpretation extends AbstractSqmPathInterpretat final Clause currentClause = sqlAstCreationState.getCurrentClauseStack().getCurrent(); final SqmQueryPart sqmQueryPart = sqlAstCreationState.getCurrentSqmQueryPart(); if ( ( currentClause == Clause.GROUP || currentClause == Clause.SELECT || currentClause == Clause.ORDER || currentClause == Clause.HAVING ) - && sqmPath.getLhs() instanceof SqmFrom + && lhs instanceof SqmFrom && modelPartContainer.getPartMappingType() instanceof ManagedMappingType && sqmQueryPart.isSimpleQueryPart() && sqmQueryPart.getFirstQuerySpec().groupByClauseContains( sqmPath.getNavigablePath() ) ) {