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

后端 未结 4 927
春和景丽
春和景丽 2020-12-15 15:10

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

4条回答
  •  鱼传尺愫
    2020-12-15 15:31

    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
    

提交回复
热议问题