Skip to content

Commit 8635250

Browse files
committed
HHH-18069 NullPointerException when unioning partition results
1 parent fce9212 commit 8635250

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1989,6 +1989,8 @@ public QueryGroup visitQueryGroup(SqmQueryGroup<?> queryGroup) {
19891989
(SqmAliasedNodeCollector) lastPoppedProcessingState.getSqlExpressionResolver()
19901990
);
19911991

1992+
final FromClauseIndex firstQueryPartIndex = lastPoppedFromClauseIndex;
1993+
19921994
visitOrderByOffsetAndFetch( queryGroup, group );
19931995

19941996
trackSelectionsForGroup = false;
@@ -1997,6 +1999,10 @@ public QueryGroup visitQueryGroup(SqmQueryGroup<?> queryGroup) {
19971999
newQueryParts.add( visitQueryPart( queryParts.get( i ) ) );
19982000
}
19992001

2002+
// Register the table groups from the first sub-queryspec's FromClauseIndex
2003+
// as they might be needed to resolve the tuple type's table groups
2004+
firstQueryPartIndex.copyInto( fromClauseIndexStack.getCurrent() );
2005+
20002006
return group;
20012007
}
20022008
finally {

hibernate-core/src/main/java/org/hibernate/query/sqm/sql/FromClauseIndex.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.HashMap;
88
import java.util.Map;
99

10+
import org.hibernate.Internal;
1011
import org.hibernate.spi.NavigablePath;
1112
import org.hibernate.query.sqm.tree.domain.SqmPath;
1213
import org.hibernate.query.sqm.tree.from.SqmAttributeJoin;
@@ -89,4 +90,9 @@ public boolean isResolved(SqmFrom fromElement) {
8990
public SqmAttributeJoin findFetchedJoinByPath(NavigablePath path) {
9091
return fetchesByPath == null ? null : fetchesByPath.get( path.getIdentifierForTableGroup() );
9192
}
93+
94+
@Internal
95+
public void copyInto(FromClauseIndex index) {
96+
index.tableGroupMap.putAll( tableGroupMap );
97+
}
9298
}

0 commit comments

Comments
 (0)