Hibernate genericDao投影

时间:2015-07-20 09:07:17

标签: hibernate genericdao

我使用Hibernate 4.2.7.Final和Google genericDAO 1.2.0。我对如何用group by编写搜索感兴趣?

例如:

select a, sum(b) from table group by a

Search search = new Search();
search.addFieldGroupBy("a"); //this does not exist, I need something like this
search.addField("b", Field.OP_SUM);

1 个答案:

答案 0 :(得分:1)

在hibernate group by query中与你的本机SQL相同,那么你将拥有你的持久对象名称。

select a, sum(b) from table t group by t.a