-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Weird behaviour
PostPosted: Thu Sep 25, 2003 9:38 am 
Newbie

Joined: Thu Sep 25, 2003 9:25 am
Posts: 15
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 9:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yes, this is a known bug. Fixing it is not an especially high priority. There is an existing JIRA issue.


Top
 Profile  
 
 Post subject: How do I get around the bug
PostPosted: Thu Sep 25, 2003 9:59 am 
Newbie

Joined: Thu Sep 25, 2003 9:25 am
Posts: 15
Thanks for the reply. Is there any workaround for this probem?

I also tried find(String query, Object[] values, Type[] types)
but got the same error...


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 25, 2003 10:01 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Use positional parameters, and reverse the order. Ugly, but ut works.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.