Variable naming when expanding collection-values JPQL parameters causes name collisions

Description

When issuing a JPQL query to the database that uses multiple, similarly named, collection-valued parameters that have names ending in numbers, such as :foo0, :foo1, ..., :foo11, the parameters are internally expanded to foo00_, foo01_, so IN(:foo0) becomes IN($foo00_, foo01_, ...) Unfortunately, this means that the 11th element of :foo1 becomes $foo110_ and the 1st element of :foo11 becomes $foo110_ AS WELL. This causes the generation of erroneous database requests, the loss of rows that should be returned and the return of rows that were not requested. In the SQL query, the SQL variables are assigned incorrect values.

Workaround: Do not use JPQL parameters that end in numbers, terminate with letters (:foo0x, :foo1x, ..., :foo11x).

Environment

Hibernate 3.3.1 as provided by JBoss 5.1.0.GA on Ubuntu x86_64 8.10 and Oracle (Sun) Java 1.6.0_20 using PostgreSQL 8.4.4

Activity

Show:
Brett Meyer
December 11, 2013, 3:28 AM

Cannot reproduce – these are now translated to positional parameters.

Cannot Reproduce

Assignee

Brett Meyer

Reporter

Simon Dierl

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor