From b6ee7918e751d4b45cbb381a5b74a44715ffd6ab Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 27 Nov 2024 11:50:01 +0100 Subject: [PATCH] HHH-18069 NullPointerException when unioning partition results --- .../hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index 3bd91f0e97..fea924ee63 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -1982,9 +1982,13 @@ public abstract class BaseSqmToSqlAstConverter extends Base sqmQueryPartStack.push( queryGroup ); pushProcessingState( processingState ); + FromClauseIndex firstQueryPartIndex = null; + SqlAstProcessingState firstPoppedProcessingState = null; try { newQueryParts.add( visitQueryPart( queryParts.get( 0 ) ) ); + firstQueryPartIndex = lastPoppedFromClauseIndex; + firstPoppedProcessingState = lastPoppedProcessingState; collector.setSqmAliasedNodeCollector( (SqmAliasedNodeCollector) lastPoppedProcessingState.getSqlExpressionResolver() ); @@ -2002,6 +2006,8 @@ public abstract class BaseSqmToSqlAstConverter extends Base finally { popProcessingStateStack(); sqmQueryPartStack.pop(); + lastPoppedFromClauseIndex = firstQueryPartIndex; + lastPoppedProcessingState = firstPoppedProcessingState; } }