mysql中sql語句的ifnull函數,在hibernate的hql中可用coalesce代替。
例:
mysql的sql:select ifnull(max(sort),0) from table;
hibernate的hql:select coalesce(max(sort),0) from table;
經測試,這2個sql在mysql中都能執行:
select ifnull(max(sort),0) from table;
select coalesce(max(sort),0) from table;
----------------------------------------------------------------------------------------
參考:https://forum.hibernate.org/viewtopic.php?f=1&t=938874
