Skip to content

Commit 278ad6a

Browse files
committed
HHH-17104 More consistent function argument return type checking
1 parent 8914f5b commit 278ad6a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/StandardFunctionReturnTypeResolvers.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.hibernate.metamodel.mapping.BasicValuedMapping;
1717
import org.hibernate.metamodel.mapping.JdbcMapping;
1818
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
19+
import org.hibernate.metamodel.model.domain.EntityDomainType;
1920
import org.hibernate.query.ReturnableType;
2021
import org.hibernate.query.sqm.SqmExpressible;
2122
import org.hibernate.query.sqm.SqmPathSource;
@@ -108,10 +109,9 @@ public ReturnableType<?> resolveFunctionReturnType(
108109
ReturnableType<?> impliedType,
109110
List<? extends SqmTypedNode<?>> arguments,
110111
TypeConfiguration typeConfiguration) {
111-
for ( SqmTypedNode<?> arg : arguments ) {
112-
final SqmExpressible<?> argumentNodeType = arg != null ? getArgumentExpressible( arg ) : null;
113-
if ( argumentNodeType instanceof ReturnableType ) {
114-
ReturnableType<?> argType = (ReturnableType<?>) argumentNodeType;
112+
for ( int i = 0; i < arguments.size(); i++ ) {
113+
if ( arguments.get( i ) != null ) {
114+
final ReturnableType<?> argType = extractArgumentType( arguments, i + 1 );
115115
return isAssignableTo( argType, impliedType ) ? impliedType : argType;
116116
}
117117
}
@@ -214,7 +214,7 @@ public static ReturnableType<?> extractArgumentType(
214214
int position) {
215215
final SqmTypedNode<?> specifiedArgument = arguments.get( position - 1 );
216216
final SqmExpressible<?> specifiedArgType = getArgumentExpressible( specifiedArgument );
217-
if ( !(specifiedArgType instanceof ReturnableType ) ) {
217+
if ( specifiedArgType != null && !(specifiedArgType instanceof ReturnableType ) ) {
218218
throw new QueryException(
219219
String.format(
220220
Locale.ROOT,

0 commit comments

Comments
 (0)