Currently we let you bind a list of values to a criteria query parameter by using something like:
Unfortunately this isn’t properly type-safe, and righty results in a compiler warning. One of the tests does this instead:
JpaParameterExpression<List<Integer>> param = cb.parameter( (Class<List<Integer>>) (Class<?>) List.class );
But that ugliness is actually no better, it’s an unchecked cast, which again results in a compiler warning. I also noticed that the implementation of this, SqmCriteriaNodeBuilder.MultiValueParameterType requires special-case handling in the HQL type-checking code, which is pretty nasty. Now, JPA does not require this, and from the git history it appears that we only implemented in H6 in order to support integration with Search which must use this. I propose that we replace this with something better, in HibernateCriteriaBuilder:
<T> JpaParameterExpression<List<T>> parameterList(Class<T> paramClass);
<T> JpaParameterExpression<List<T>> parameterList(Class<T> paramClass, String name);
and figure out a way to migrate people away from the use of the raw type. |