Fix resolving parameter type if other side is a subquery returning a collection part

This commit is contained in:
Christian Beikov 2021-08-05 11:41:25 +02:00
parent b30c9aea8e
commit 62514e9e53
1 changed files with 20 additions and 0 deletions

View File

@ -2646,6 +2646,26 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
if ( selectionNodeType instanceof PluralPersistentAttribute ) { if ( selectionNodeType instanceof PluralPersistentAttribute ) {
sqmExpressable = ( (PluralPersistentAttribute<?,?,?>) selectionNodeType ).getElementPathSource(); sqmExpressable = ( (PluralPersistentAttribute<?,?,?>) selectionNodeType ).getElementPathSource();
} }
else if ( selectionNodeType instanceof SqmPathSource<?>) {
final SqmPathSource<?> pathSource = (SqmPathSource<?>) selectionNodeType;
final CollectionPart.Nature partNature = CollectionPart.Nature.fromName(
pathSource.getPathName()
);
if ( partNature == null ) {
sqmExpressable = selectionNodeType;
}
else {
final SqmPath<?> sqmPath = (SqmPath<?>) subQuerySelection.getSelectableNode();
final NavigablePath navigablePath = sqmPath.getNavigablePath().getParent();
if ( navigablePath.getParent() != null ) {
final TableGroup parentTableGroup = findTableGroup( navigablePath.getParent() );
final PluralAttributeMapping pluralPart = (PluralAttributeMapping) parentTableGroup.getModelPart()
.findSubPart( navigablePath.getUnaliasedLocalName(), null );
return pluralPart.findSubPart( pathSource.getPathName(), null );
}
return findTableGroup( navigablePath ).getModelPart();
}
}
else { else {
sqmExpressable = selectionNodeType; sqmExpressable = selectionNodeType;
} }