Hibernate getParameterValue() not working for collections

Viewed 354

I have a function like the following in a JPA Helper class:

 public static Query copyQueryParameters(Query queryFrom, Query queryTo) {
    for (Parameter<?> param : queryFrom.getParameters()) {
        queryTo.setParameter(param.getName(), 
        queryFrom.getParameterValue(param));
    }
    return queryTo;
 }

which used to work well before I upgrade to Hibernate 5+. Now, every time I try to find a parameter which is a collection or array it throws an IllegalArgumentException telling the value was not found. It does work for all non-collection parameters.

Caused by: java.lang.IllegalArgumentException: Unknown parameter name : _status

_status in this case is a List of enum. But it doesn't work with any other kind of multi-valued params such as arrays or maps.

I have been using this to copy params from one query to another in order to make it possible to make a select count... without having to re-set all the query params.

Anyone else is facing this problem?

0 Answers
Related