There is a bug in naming parameters in org.hibernate.impl.AbstractQueryImpl.expandParameterList(String, String, TypedValue, Map).
When the number of parameters in HQL is >10, and there is more than one parameter with multiple values (there is IN clause), then there is a chance, that values from second IN clause will override values from first IN clause.
Query is in JPA style
Lets assume that ?1 is a collection of 14 elements, and ?11 is collection of 5 elements.
According to logic in aforementioned method parameters created from ?1 will be named x10_... to x110_, x111_, x112_, x113_.
Parameters created from ?11 will be named x110_, x111_, x112_, x113_, x114_ .
First four will override last four from ?1.
I think that underscore should be added or moved between 'x' and param index.
This was found in 3.6.10, but as I check, same code exists in 4.2.2 version.