With criteria builder, I’m calling a function which has a collection as parameter. This fails with a NullPointerException when hibernate validates the types.
My code (simplified), where I define a generic “contains in array” check.
{ noformat code:java } protected <T> Predicate contains(Expression<Collection<T>> array, Expression< T > value) { return criteriaBuilder.equal( criteriaBuilder.literal( value ) , criteriaBuilder.function("ANY", Object.class, array)); }{ noformat code }
This fails at {{ArgumentTypesValidator.validate:92}} with a {{NullPointerException}}:
{{final JdbcType jdbcType = getJdbcType( queryEngine, argument, indicators, javaType );}} // → null {{jdbcType.getDefaultSqlTypeCode()}} → NullPointerException The {{ArgumentTypesValidator.getJdbcType:139}} calls {{javaType.getRecommendedJdbcType}} and {{CollectionJavaType.getRecommendedJdbcType}} always returns {{null}}. I think that {{ArgumentTypesValidator.validate}} should handle a {{null}} jdbcType properly, in that case not doing the validation.
Or what is your opinion? Is there a workaround? |
|