From afd3bee28ee1380f224065dc4fae2c619bcafe16 Mon Sep 17 00:00:00 2001 From: Andrea Boriero Date: Wed, 28 Jun 2023 15:06:29 +0200 Subject: [PATCH] HHH-15720 Using multiple select in a multiselect generates java.lang.ArrayIndexOutOfBoundsException --- .../query/sqm/sql/BaseSqmToSqlAstConverter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 da44cceddd..ad8eb2ac32 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 @@ -8241,7 +8241,15 @@ public abstract class BaseSqmToSqlAstConverter extends Base offset = countIndividualSelections( ( (SqmDynamicInstantiation) selectableNode ).getArguments() ) - 1; } else if ( selectableNode instanceof SqmJpaCompoundSelection ) { - offset += ( (SqmJpaCompoundSelection) selectableNode ).getSelectionItems().size() - 1; + for ( SqmSelectableNode node : ( (SqmJpaCompoundSelection) selectableNode ).getSelectionItems() ) { + if ( node instanceof SqmDynamicInstantiation ) { + offset += countIndividualSelections( ( (SqmDynamicInstantiation) node ).getArguments() ) ; + } + else { + offset += 1; + } + } + offset -= 1; } } return offset + selections.size();