]
Diego Pires Plentz resolved HHH-176.
------------------------------------
Assignee: Diego Pires Plentz
Resolution: Duplicate
This issue is older then HHH-1423, but has less info. Closing as dup.
Incorrect binding of parameters in HQL query with []
----------------------------------------------------
Key: HHH-176
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-176
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.0 rc 1
Environment: MySQL 4.1.7
Reporter: William Drai
Assignee: Diego Pires Plentz
Priority: Minor
The bindings of the named parameters are
completely inverted in the following query, where props is just a map of integers indexed
by integers.
select user from User user where user.propsIds[:moduleId] = :propId and user.serviceId =
:serviceId and user.serviceDb = :serviceDb
With the classic HQL parser, the generated SQL is something like :
select u.xxx, .. from USER u, USER_PROPERTY up where up.PROP_ID = ? and u.USER_ID = u.ID
and up.MODULE_ID = ? and u.SERVICE_ID = ? and u.SERVICE_DB = ?
In this case, the parameter :moduleId is binded at position 0, and the parameter :propId
is binded at position 1.
This is not the right order but as I also made a mistake in my code, the end result was
right... This bug was certainly present in all the versions of HB 2.1 we have used so far
and in fact we have been living with it without even knowing it.
Since we are migrating to HB3, we are trying the new AST parser and this bug has not been
corrected, but it behaves differently, so we could discover it.
The new parser produces the following SQL :
select u.xxx, .. from USER u, USER_PROPERTY up where up.PROP_ID = ?
and u.USER_ID = u.id and u.SERVICE_ID = ? and u.SERVICE_DB = ? and up.MODULE_ID = ?
The parameter :moduleId is binded at position 0, propId at 1, serviceId at 2 and
serviceDb at 3. Everything is messed up.
Fortunately, as all of these parameters are integers, we still have the ability to find a
workaround by inverting the values we set but
it would of course be better to have a patch.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: