IFNULL equivalent in Hibernate Query Language?

后端 未结 2 1603
夕颜
夕颜 2021-02-07 09:51

I\'m trying to write an HQL query which will calculate an average rating for an item. I want the query to return 0 instead of null when there are no rating for a given item - so

2条回答
  •  佛祖请我去吃肉
    2021-02-07 10:38

    Nhibernate docs are out of date. Check http://docs.jboss.org/hibernate/stable/core/reference/en/html/queryhql.html

    If nothing works you can try:

    select 
       case 
         when something is not NULL then 0
         else 
       end
    

提交回复
热议问题