HHH-11971 - QueryParameterBindingValidator does not handle primitive types

This commit is contained in:
Andrea Boriero 2017-10-14 17:30:36 +01:00
parent 4979241a1d
commit 07eec26d67
1 changed files with 29 additions and 3 deletions

View File

@ -86,11 +86,37 @@ public class QueryParameterBindingValidator {
} }
private static boolean isValidBindValue(Class expectedType, Object value, TemporalType temporalType) { private static boolean isValidBindValue(Class expectedType, Object value, TemporalType temporalType) {
if ( expectedType.isInstance( value ) ) { if ( expectedType.isPrimitive() ) {
if ( expectedType == boolean.class ) {
return Boolean.class.isInstance( value );
}
else if ( expectedType == char.class ) {
return Character.class.isInstance( value );
}
else if ( expectedType == byte.class ) {
return Byte.class.isInstance( value );
}
else if ( expectedType == short.class ) {
return Short.class.isInstance( value );
}
else if ( expectedType == int.class ) {
return Integer.class.isInstance( value );
}
else if ( expectedType == long.class ) {
return Long.class.isInstance( value );
}
else if ( expectedType == float.class ) {
return Float.class.isInstance( value );
}
else if ( expectedType == double.class ) {
return Double.class.isInstance( value );
}
return false;
}
else if ( expectedType.isInstance( value ) ) {
return true; return true;
} }
else if ( temporalType != null ) {
if ( temporalType != null ) {
final boolean parameterDeclarationIsTemporal = Date.class.isAssignableFrom( expectedType ) final boolean parameterDeclarationIsTemporal = Date.class.isAssignableFrom( expectedType )
|| Calendar.class.isAssignableFrom( expectedType ); || Calendar.class.isAssignableFrom( expectedType );
final boolean bindIsTemporal = Date.class.isInstance( value ) final boolean bindIsTemporal = Date.class.isInstance( value )