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.  [ 3 posts ] 
Author Message
 Post subject: Querying with query.setBoolean() ignores query.substitutions
PostPosted: Wed Jul 13, 2005 1:24 pm 
Newbie

Joined: Fri Jul 08, 2005 6:24 pm
Posts: 3
We are using hibernate 3.0.5.

I have the following property defined in my hibernate configuration file:
<property name="hibernate.query.substitutions">true 'Y', false 'N', yes 'Y', no 'N'</property>

Instances of User class are persisted using hibernate. active is an instance variable of the User class and its hibernate type is "yes_no" and its java type is java.lang.Boolean. In the database, it is stored as a CHAR(1) ('Y' or 'N'). So, the following HQL works fine:

"select user from User user where user.active=true"

Executing the above query works as expected (true is "changed" to 'Y' by hibernate). We do get the number of expected results. However, the following does not work (I get no results back):

String str = "select user from User user where user.active=:activeState";
Query query = session.createQuery(str);
query.setParameter("activeState", new Boolean(true));

Executing this query gives me no results back. We also tried the following with no luck:

String str = "select user from User user where user.active=:activeState";
Query query = session.createQuery(str);
query.setBoolean("activeState", true);

We got same behavior: no results back.

Am I missing something here or this is just not supposed to work? Thanks.


Top
 Profile  
 
 Post subject: Still same problem...
PostPosted: Tue Jul 19, 2005 2:27 pm 
Newbie

Joined: Fri Jul 08, 2005 6:24 pm
Posts: 3
I am still having the problem desribed above... Has any one come across this problem or am I just missing something here?

Aren't query substitutions supposed to work when using query parameters?

String str = "select user from User user where user.active=:activeState";
Query query = session.createQuery(str);
query.setParameter("activeState", new Boolean(true));


Top
 Profile  
 
 Post subject: Re: Still same problem...
PostPosted: Tue Jul 19, 2005 2:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
rolivieri wrote:
Aren't query substitutions supposed to work when using query parameters?



No.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.