HQL “is null” And “!= null” on an Oracle column

2019-01-25 01:16发布

Does hibernate convert column != null in HQL to a column is null in SQL?

4条回答
Luminary・发光体
2楼-- · 2019-01-25 01:42

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"); // Works
query.setParameter("param", null);          // Works also
查看更多
走好不送
3楼-- · 2019-01-25 01:45

No. See also this link Handle conditional null in HQL for tips and tricks on how to handle comparisons with both null and non-null values.

查看更多
男人必须洒脱
4楼-- · 2019-01-25 01:53

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

查看更多
Lonely孤独者°
5楼-- · 2019-01-25 02:08

That is a binary operator in hibernate you should use

is not null

Have a look at 14.10. Expressions

查看更多
登录 后发表回答