如何使用条件和投影在hibernate中实现以下代码:
is_featured
答案 0 :(得分:2)
查询可以更改为:select CUSTOMER_NO, count(*) as count from temp.t group by CUSTOMER_NO order by count desc limit 1;
同样的标准是:
criteria.setProjection(Projections.projectionList().add(Projections.groupProperty("CUSTOMER_NO")).add(Projections.rowCount(), "count"));
criteria.addOrder(Order.desc("count"));
criteria.setMaxResults(1);
return criteria.list();