1

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);
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
KatieAmber
  • 77
  • 12

1 Answers1

1

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
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
Kulbhushan Singh
  • 627
  • 4
  • 20
  • Sorry, I updated my question, coz I know that this is the query but now I need a Search object for groupping by a field. – KatieAmber Jul 21 '15 at 08:56