CASE statement in HQL or Criteria

后端 未结 1 1880
暖寄归人
暖寄归人 2020-12-18 04:21

derived from this question, is it possible to use HQL or Criteria for the following SQL statement:

SELECT 
   e.type, 
   count(e), 
   count(d), 
   count (         


        
相关标签:
1条回答
  • 2020-12-18 04:44

    Well, it seems, case statements are supported:

    http://docs.jboss.org/hibernate/core/3.5/reference/en/html/queryhql.html

    They just don't seem to work within count(). An alternative would be using sum(case when... then 1 else 0 end) instead

    0 讨论(0)
提交回复
热议问题