【发布时间】:2015-01-05 01:22:35
【问题描述】:
如何将此查询转换为休眠条件:
Select cat, sum(amount)
from transaction
where customer =: customer
and month =: month
and year = year
group by cat;
我目前的标准是:
Select cat, sum(amount)
from transaction
where customer =: customer
group by cat;
Criteria cx = getCriteria()
.setProjection(Projections.projectionList()
.add(Projections.sum("amount", "amount")
.add(Projections.groupProperty("cat", "cat")
)
.add(Restrictions.eq("customer", customer))
;
我尝试了很多方法,例如 .add(Restrictions.eq("month(createOn)", month) 但我收到了这个错误:
org.hibernate.QueryException: could not resolve property: month(createOn) of: com.transaction
我已确保我有数据类型为日期的 createOn 字段,并且没有语法错误。
【问题讨论】:
标签: hibernate