HHH-17104 More consistent function argument return type checking

This commit is contained in:
Marco Belladelli 2023-08-30 12:43:56 +02:00
parent 8914f5bc65
commit 278ad6a109
1 changed files with 5 additions and 5 deletions

View File

@ -16,6 +16,7 @@ import org.hibernate.QueryException;
import org.hibernate.metamodel.mapping.BasicValuedMapping;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.query.ReturnableType;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.SqmPathSource;
@ -108,10 +109,9 @@ public class StandardFunctionReturnTypeResolvers {
ReturnableType<?> impliedType,
List<? extends SqmTypedNode<?>> arguments,
TypeConfiguration typeConfiguration) {
for ( SqmTypedNode<?> arg : arguments ) {
final SqmExpressible<?> argumentNodeType = arg != null ? getArgumentExpressible( arg ) : null;
if ( argumentNodeType instanceof ReturnableType ) {
ReturnableType<?> argType = (ReturnableType<?>) argumentNodeType;
for ( int i = 0; i < arguments.size(); i++ ) {
if ( arguments.get( i ) != null ) {
final ReturnableType<?> argType = extractArgumentType( arguments, i + 1 );
return isAssignableTo( argType, impliedType ) ? impliedType : argType;
}
}
@ -214,7 +214,7 @@ public class StandardFunctionReturnTypeResolvers {
int position) {
final SqmTypedNode<?> specifiedArgument = arguments.get( position - 1 );
final SqmExpressible<?> specifiedArgType = getArgumentExpressible( specifiedArgument );
if ( !(specifiedArgType instanceof ReturnableType ) ) {
if ( specifiedArgType != null && !(specifiedArgType instanceof ReturnableType ) ) {
throw new QueryException(
String.format(
Locale.ROOT,