]
Olivier BILLIARD commented on HHH-3303:
---------------------------------------
I have the same problem with the 3.3.1 GA version when I want to do an In expression with
PK objects.
I debug my program and the Hibernate API. I found a problem in the InExpression class.
There is a double loop which prepare the parameters valuers for the query. The order of
the loops is wrong and must be switched.
I attach the corrected file. It's working in my case but It surely need some more
check to be sure it works in all cases.
Parameters bound in wrong order for IN-clauses on dynamic components
--------------------------------------------------------------------
Key: HHH-3303
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3303
Project: Hibernate Core
Issue Type: Bug
Components: query-criteria
Affects Versions: 3.2.6
Reporter: Holger Engels
Attachments: BugTest.java, Entity.java, HibernateBug.hbm.xml
When issuing the following query, the parameters are bound in wrong order:
List<Map> keys = Arrays.asList(CollectionUtil.map("mandator",
"M", "key", "test"),
CollectionUtil.map("mandator", "M", "key",
"user"));
list = session.createCriteria(Profile.class).add(Restrictions.in("key",
keys)).list();
// list.size() = 0, should be 2
[DEBUG] 15:24:45 [org.hibernate.SQL ]: select this_.id as id7_0_, this_.version as
version7_0_, this_.key_mandator as key3_7_0_, this_.key_key as key4_7_0_, this_.created as
created7_0_, this_.createdBy as createdBy7_0_, this_.modified as modified7_0_, this_.name
as name7_0_ from auth_profile this_ where (this_.key_mandator, this_.key_key) in ((?, ?),
(?, ?))
Hibernate: select this_.id as id7_0_, this_.version as version7_0_, this_.key_mandator as
key3_7_0_, this_.key_key as key4_7_0_, this_.created as created7_0_, this_.createdBy as
createdBy7_0_, this_.modified as modified7_0_, this_.name as name7_0_ from auth_profile
this_ where (this_.key_mandator, this_.key_key) in ((?, ?), (?, ?))
[DEBUG] 15:24:45 [nate.jdbc.AbstractBatcher]: preparing statement
[DEBUG] 15:24:45 [hibernate.type.StringType]: binding 'M' to parameter: 1
[DEBUG] 15:24:45 [hibernate.type.StringType]: binding 'M' to parameter: 2
[DEBUG] 15:24:45 [hibernate.type.StringType]: binding 'test' to parameter: 3
[DEBUG] 15:24:45 [hibernate.type.StringType]: binding 'user' to parameter: 4
It should be:
binding 'M' to parameter: 1
binding 'test' to parameter: 2
binding 'M' to parameter: 3
binding 'user' to parameter: 4
The mapping for key is:
<dynamic-component name="key" unique="true">
<property name="mandator" column="key_mandator"
type="string" length="4"/>
<property name="key" column="key_key"
type="string" length="16"/>
</dynamic-component>
Interestingly, the same query works in HQL:
Query query = session.createQuery("from Profile where key in
(:keys)");
query.setParameterList("keys", keys);
list = query.list();
// list.size() = 2
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: