Skip to content

Commit

Permalink
HHH-17530 Handle nested dynamic instantiations when tracking selections
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel authored and beikov committed Jan 4, 2024
1 parent f0b2eb9 commit 8692e3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8497,21 +8497,23 @@ private static int countIndividualSelections(List<? extends SqmAliasedNode<?>> s
for ( int i = 0; i < selections.size(); i++ ) {
final SqmSelectableNode<?> selectableNode = selections.get( i ).getSelectableNode();
if ( selectableNode instanceof SqmDynamicInstantiation<?> ) {
offset = countIndividualSelections( ( (SqmDynamicInstantiation<?>) selectableNode ).getArguments() ) - 1;
offset += countIndividualSelections( ( (SqmDynamicInstantiation<?>) selectableNode ).getArguments() );
}
else if ( selectableNode instanceof SqmJpaCompoundSelection<?> ) {
for ( SqmSelectableNode<?> node : ( (SqmJpaCompoundSelection<?>) selectableNode ).getSelectionItems() ) {
if ( node instanceof SqmDynamicInstantiation<?> ) {
offset += countIndividualSelections( ( (SqmDynamicInstantiation<?>) node ).getArguments() ) ;
offset += countIndividualSelections( ( (SqmDynamicInstantiation<?>) node ).getArguments() );
}
else {
offset += 1;
}
}
offset -= 1;
}
else {
offset += 1;
}
}
return offset + selections.size();
return offset;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ public ArgumentDomainResult<T> buildArgumentDomainResult(DomainResultCreationSta
.getCurrentProcessingState()
.getSqlExpressionResolver();
if ( sqlExpressionResolver instanceof BaseSqmToSqlAstConverter.SqmAliasedNodeCollector ) {
( (BaseSqmToSqlAstConverter.SqmAliasedNodeCollector) sqlExpressionResolver ).next();
if ( !( argumentResultProducer instanceof DynamicInstantiation<?> ) ) {
( (BaseSqmToSqlAstConverter.SqmAliasedNodeCollector) sqlExpressionResolver ).next();
}
}
return new ArgumentDomainResult<>( argumentResultProducer.createDomainResult( alias, creationState ) );
}
Expand Down

0 comments on commit 8692e3d

Please sign in to comment.