-->
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.  [ 1 post ] 
Author Message
 Post subject: null = null true HQL How?
PostPosted: Fri May 18, 2007 11:06 am 
Newbie

Joined: Fri May 18, 2007 10:59 am
Posts: 3
I have a query that needs to also match nulls and I imagine there is a way to configure hibernate to do this automatically but have not found it.

Basically I would like the following to also evaluate true for when both the column and java object are null. At the moment because null = null evaluates as false the query never returns results. Is there a way to tell hibernate to treat empty strings and nulls as identical and produce SQL that will do this? Some databases treat empty strings as nulls..

Code:
Query q = getSession()
            .createQuery(
                  "from IndividualCheckDO check where "
                          + "check.applicant.name.title = :title "
                        + "and check.applicant.name.forename = :forename "
                        + "and check.applicant.name.surname = :surname "
                        + "and check.current_address.flat_number = :flat_number "
                        + "and check.current_address.flat_name = :flat_name "
                        + "and check.current_address.house_name = :house_name "
                        + "and check.current_address.house_number = :house_number "
                        + "and check.current_address.street = :street "
                        + "and check.current_address.postcode = :postcode");
      q.setString("title", name.getTitle());
      q.setString("forename", name.getForename());
      q.setString("surname", name.getSurname());
      q.setString("flat_number", address.getFlat_number());
      q.setString("flat_name", address.getFlat_name());
      q.setString("house_name", address.getHouse_name());
      q.setString("house_number", address.getHouse_number());
      q.setString("street", address.getStreet());
      q.setString("postcode", address.getPostcode());


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

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.