-->
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: JPQL parameters and null values
PostPosted: Fri May 11, 2007 8:05 am 
Newbie

Joined: Mon Nov 27, 2006 7:38 am
Posts: 7
Hi,

Is there a good way of doing where-clauses with null values?

Comparison or arithmetic operations with a NULL value always yield an unknown value.

Hence the following does not work
Code:
SELECT e FROM Employee e WHERE e.name = NULL
It has to be
Code:
SELECT e FROM Employee e WHERE e.name IS NULL


Using named or positional parameters this becomes a problem. The code below won't work:
Code:
String myJPQL = "SELECT e FROM Employee e WHERE e.name = :name";
List results = em.createQuery(myJPQL)
                 .setParameter("name", null)
                 .getResultList();


Do I really have to create two JPQL statements to handle this issue?

Thanks,
Skipper


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 14, 2007 12:19 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
named parameters can be used multiple times in queries

_________________
Emmanuel


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.