-->
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: HQL query with a null parameter?
PostPosted: Wed May 19, 2004 10:16 am 
Beginner
Beginner

Joined: Tue Jan 27, 2004 8:25 am
Posts: 45
Hi all!

I'm trying to create a HQl query with a null value in the where clause...

This is my class:

Code:

public class Reservation implements Serializable
{
   private Long code;
   private TravelFileHeader travelFileHeader;
   private String fileName;
   private Calendar creationDate;
   private Calendar startDate;
   private Calendar endDate;
   private Reservation controlReservation;
   private Reservation replacesReservation;
   private Reservation isReplacedByReservation;
   private boolean isOnRequest;
   private Service service;
   private ParsysUser parsysUser;
   private String confirmationStatus;
   private BranchOffice branchOffice;
   private String reservationType;
   
   private Set comments;
//getters and setters follows...
}


So what I'm trying to do is to get all the reservations form Rservation table where isReplacedByReservation is null....



Code:
List rsList = HibernateSession.currentSession().createQuery("from Reservation as res where res.travelFileHeader.code = " + travelFile.getCode().longValue() + " and res.isReplacedByReservation = null").list();


But I get no records back... how should I do this correctly?
Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 19, 2004 10:40 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use "is null" and not "= null". HQL obeys to the same ternary logic as SQL.


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.