mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 20:24:46 +00:00
HHH-18960 If query parameter allows multiple value binding, accept List, Set, or Collection with parameter type as generic type
This commit is contained in:
parent
c96305a2e4
commit
050089efcc
@ -64,6 +64,7 @@
|
||||
import static java.beans.Introspector.decapitalize;
|
||||
import static java.lang.Boolean.FALSE;
|
||||
import static java.util.Collections.emptyList;
|
||||
import static java.util.Objects.requireNonNullElse;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static javax.lang.model.util.ElementFilter.fieldsIn;
|
||||
import static javax.lang.model.util.ElementFilter.methodsIn;
|
||||
@ -2738,11 +2739,13 @@ private void checkParameter(
|
||||
if ( queryParamType!=null
|
||||
//TODO: arguments of functions get assigned "unknown" which sucks
|
||||
&& !"unknown".equals(queryParamType) ) {
|
||||
final String realQueryParamType =
|
||||
requireNonNullElse( context.qualifiedNameForEntityName( queryParamType ), queryParamType );
|
||||
if ( param.getName() != null ) {
|
||||
checkNamedParameter(param, paramNames, paramTypes, method, mirror, value, queryParamType);
|
||||
checkNamedParameter(param, paramNames, paramTypes, method, mirror, value, realQueryParamType);
|
||||
}
|
||||
else if ( param.getPosition() != null ) {
|
||||
checkOrdinalParameter(param, paramNames, paramTypes, method, mirror, value, queryParamType);
|
||||
checkOrdinalParameter(param, paramNames, paramTypes, method, mirror, value, realQueryParamType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,10 +148,20 @@ private void parameters(TreeSet<SqmParameter<?>> sortedParameters, StringBuilder
|
||||
declaration
|
||||
.append(", ");
|
||||
}
|
||||
declaration
|
||||
.append(parameterType(param))
|
||||
.append(" ")
|
||||
.append(parameterName(param));
|
||||
if ( param.allowMultiValuedBinding() ) {
|
||||
declaration
|
||||
.append(annotationMeta.importType(Constants.LIST))
|
||||
.append('<')
|
||||
.append( parameterType( param ) )
|
||||
.append("> ")
|
||||
.append( parameterName( param ) );
|
||||
}
|
||||
else {
|
||||
declaration
|
||||
.append( parameterType( param ) )
|
||||
.append( " " )
|
||||
.append( parameterName( param ) );
|
||||
}
|
||||
}
|
||||
declaration
|
||||
.append(')');
|
||||
|
Loading…
x
Reference in New Issue
Block a user