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