HHH-17255 Fix treated join basic path table reference resolution

This commit is contained in:
Marco Belladelli 2023-09-25 13:58:58 +02:00
parent 5b404f1248
commit 00209bb82c
1 changed files with 2 additions and 4 deletions

View File

@ -44,10 +44,8 @@ public class BasicValuedPathInterpretation<T> extends AbstractSqmPathInterpretat
SqmBasicValuedSimplePath<T> sqmPath, SqmBasicValuedSimplePath<T> sqmPath,
SqmToSqlAstConverter sqlAstCreationState, SqmToSqlAstConverter sqlAstCreationState,
boolean jpaQueryComplianceEnabled) { boolean jpaQueryComplianceEnabled) {
final FromClauseAccess fromClauseAccess = sqlAstCreationState.getFromClauseAccess();
final TableGroup tableGroup = fromClauseAccess.getTableGroup( sqmPath.getNavigablePath().getParent() );
final SqmPath<?> lhs = sqmPath.getLhs(); final SqmPath<?> lhs = sqmPath.getLhs();
final TableGroup tableGroup = sqlAstCreationState.getFromClauseAccess().getTableGroup( lhs.getNavigablePath() );
EntityMappingType treatTarget = null; EntityMappingType treatTarget = null;
final ModelPartContainer modelPartContainer; final ModelPartContainer modelPartContainer;
if ( lhs instanceof SqmTreatedPath<?, ?> ) { if ( lhs instanceof SqmTreatedPath<?, ?> ) {
@ -87,7 +85,7 @@ public class BasicValuedPathInterpretation<T> extends AbstractSqmPathInterpretat
final Clause currentClause = sqlAstCreationState.getCurrentClauseStack().getCurrent(); final Clause currentClause = sqlAstCreationState.getCurrentClauseStack().getCurrent();
final SqmQueryPart<?> sqmQueryPart = sqlAstCreationState.getCurrentSqmQueryPart(); final SqmQueryPart<?> sqmQueryPart = sqlAstCreationState.getCurrentSqmQueryPart();
if ( ( currentClause == Clause.GROUP || currentClause == Clause.SELECT || currentClause == Clause.ORDER || currentClause == Clause.HAVING ) if ( ( currentClause == Clause.GROUP || currentClause == Clause.SELECT || currentClause == Clause.ORDER || currentClause == Clause.HAVING )
&& sqmPath.getLhs() instanceof SqmFrom<?, ?> && lhs instanceof SqmFrom<?, ?>
&& modelPartContainer.getPartMappingType() instanceof ManagedMappingType && modelPartContainer.getPartMappingType() instanceof ManagedMappingType
&& sqmQueryPart.isSimpleQueryPart() && sqmQueryPart.isSimpleQueryPart()
&& sqmQueryPart.getFirstQuerySpec().groupByClauseContains( sqmPath.getNavigablePath() ) ) { && sqmQueryPart.getFirstQuerySpec().groupByClauseContains( sqmPath.getNavigablePath() ) ) {