From b4552778458b22b8baf391c0ff74226bba5dba0a Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Fri, 10 Nov 2023 15:31:42 +0100 Subject: [PATCH] HHH-17415 Improved check for entity valued path expansion in subqueries --- .../query/sqm/sql/internal/EntityValuedPathInterpretation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java index 56721ae79f..b901fc4c4f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java @@ -384,7 +384,7 @@ public class EntityValuedPathInterpretation extends AbstractSqmPathInterpreta final SqmPath sqmPath = (SqmPath) selection; // Expansion is needed if the table group is null, i.e. we're in a top level query where EVPs are always // expanded to all columns, or if the selection is on the same table (lhs) as the group by expression ... - return ( tableGroupPath == null || sqmPath.getLhs().getNavigablePath().equals( tableGroupPath ) ) + return ( tableGroupPath == null || sqmPath.getLhs() != null && sqmPath.getLhs().getNavigablePath().equals( tableGroupPath ) ) // ... and if the entity valued path is selected or any of its columns are && path.isParentOrEqual( sqmPath.getNavigablePath() ); }