HQL "is null" And "!= null" on an Oracle column HQL "is null" And "!= null" on an Oracle column oracle oracle

HQL "is null" And "!= null" on an Oracle column


That is a binary operator in hibernate you should use

is not null

Have a look at 14.10. Expressions


No. You have to use is null and is not null in HQL.


If you do want to use null values with '=' or '<>' operators you may find the

answer from @egallardo hier

very useful.

Short example for '=': The expression

WHERE t.field = :param

you refactor like this

WHERE ((:param is null and t.field is null) or t.field = :param)

Now you can set the parameter param either to some non-null value or to null:

query.setParameter("param", "Hello World"); // Worksquery.setParameter("param", null);          // Works also