I have a simple application with users and properties. My mapping:
<class name="User" table="users">
<id name="login" column="login" length="25" type="string">
<generator class="assigned" />
</id>
<map name="properties" table="user_properties" lazy="false" cascade="all">
<key column="user_id" />
<index column="prop_key" type="string" />
<element column="prop_value" type="string" />
</map>
</class>
If I create a following query:
Query query = session.createQuery("from user in class User where user.properties[:propkey]=:propvalue");
query.setString("propkey","propertyname");
query.setString("propvalue", "1");
hibernate creates a sql query like:
select user.login as login from users user, user_properties pro0_ where
(pro0_.prop_value=? and user.login=pro0_.user_id and pro0_.prop_key = ?)
which seems perfectly ok. But after than something weird happens when hibernate tries to bind the parameters to the query:
binding '1' to parameter: 2
binding 'propertyname' to parameter: 1
Now, what it SHOULD do is to bind '1' to parameter 1 and 'propertyname' to parameter 2, right? So, can anyone explain what happens here?
Thanks.
|