-->
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.  [ 2 posts ] 
Author Message
 Post subject: HOWTO - HQL where clause that can be null or have a value
PostPosted: Thu Feb 22, 2007 4:19 pm 
Newbie

Joined: Thu Jan 13, 2005 11:41 pm
Posts: 10
Lets assume I have the following HQL query:

from MyObject m
where
m.column1 = :column1 and
m.column2 = :column2 and
m.column3 = :column3

It is possible in the business logic that any of the values may be null (the values are all strings). The query works fine when all the columns have values other than null. I tried using empty string or null but it doesn't seem to return back a result.

My question is whether in the case of null, do I have to explicitly state so in the HQL query (this would mean writing lots of queries for each case)?

I think that this "problem" should be something quite common and there is probably a trivial solution which eludes me (I'm rusty).


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 4:42 pm 
Newbie

Joined: Thu Jan 13, 2005 11:41 pm
Posts: 10
I'm thinking that I may make use of the Criteria interface, though I still prefer a possible solution using the previous approach.


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