Hibernate genericDao projection

319 Views Asked by At

I'm using Hibernate 4.2.7.Final with Google genericDAO 1.2.0. I'm interested in how can I write a search with group by?

For example:

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

with

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

There are 1 best solutions below

1
Kulbhushan Singh On

In hibernate group by query is same as your native SQL other then you will have here your Persistent Object name.

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