HHH-15749 Hibernate fails when selecting grouped by entities in a specific order
This commit is contained in:
parent
a2aca9127c
commit
0745a2e294
|
@ -2288,11 +2288,11 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
|
|
||||||
private int indexOfExpression(List<? extends SqmAliasedNode<?>> selections, SqmExpression<?> node) {
|
private int indexOfExpression(List<? extends SqmAliasedNode<?>> selections, SqmExpression<?> node) {
|
||||||
final int result = indexOfExpression( 0, selections, node );
|
final int result = indexOfExpression( 0, selections, node );
|
||||||
if ( result < 1 ) {
|
if ( result < 0 ) {
|
||||||
return -result;
|
return -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return -1;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2308,27 +2308,27 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
||||||
( (SqmDynamicInstantiation<?>) selectableNode ).getArguments(),
|
( (SqmDynamicInstantiation<?>) selectableNode ).getArguments(),
|
||||||
node
|
node
|
||||||
);
|
);
|
||||||
if ( subResult < 0 ) {
|
if ( subResult >= 0 ) {
|
||||||
return subResult;
|
return subResult;
|
||||||
}
|
}
|
||||||
offset = subResult - i;
|
offset = -subResult - i;
|
||||||
}
|
}
|
||||||
else if ( selectableNode instanceof SqmJpaCompoundSelection<?> ) {
|
else if ( selectableNode instanceof SqmJpaCompoundSelection<?> ) {
|
||||||
final List<SqmSelectableNode<?>> selectionItems = ( (SqmJpaCompoundSelection<?>) selectableNode ).getSelectionItems();
|
final List<SqmSelectableNode<?>> selectionItems = ( (SqmJpaCompoundSelection<?>) selectableNode ).getSelectionItems();
|
||||||
for ( int j = 0; j < selectionItems.size(); j++ ) {
|
for ( int j = 0; j < selectionItems.size(); j++ ) {
|
||||||
if ( selectionItems.get( j ) == node ) {
|
if ( selectionItems.get( j ) == node ) {
|
||||||
return -( offset + i + j );
|
return offset + i + j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset += selectionItems.size();
|
offset += selectionItems.size();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( selectableNode == node ) {
|
if ( selectableNode == node ) {
|
||||||
return -( offset + i );
|
return offset + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return offset + selections.size();
|
return -( offset + selections.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean selectClauseContains(SqmFrom<?, ?> from) {
|
private boolean selectClauseContains(SqmFrom<?, ?> from) {
|
||||||
|
|
Loading…
Reference in New Issue