We're updating the issue view to help you get more done. 

Wrong bindings of named parameters in IN clause

Description

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.

Example:

Query is in JPA style

1 2 3 4 select c from Cat c where c.furColor IN (?1) and ... --parameters from ?2 to ?10 and c.legsNo IN (?11)

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.

Environment

3.2.10, H2

Status

Assignee

Lukasz Antoniak

Reporter

Marcin Kwaczyński

Labels

Components

Fix versions

Affects versions

3.6.10

Priority

Major