I want to get the row count of 2 different values from the database.How i write the hibernate criteria query for that? For example, in my table contain a field named 'status' and its values are 0 and 1.How could i get how many 0 and how many 1 are in my table?
Asked
Active
Viewed 454 times
1 Answers
0
This will do
select count(status) from table group by status
Hibernate Criteria
List result = session.createCriteria(Table.class)
.setProjection(Projections.projectionList()
.add(Projections.groupProperty("status"))
.add(Projections.count("status"))
).list();

Vinit Prajapati
- 1,593
- 1
- 17
- 29
-
I have another doubt ..How to integrate two criteria queries of different tables into one? – salna K May 01 '13 at 09:47
-
Check this: http://stackoverflow.com/questions/8726396/hibernate-criteria-join-with-3-tables – Vinit Prajapati May 01 '13 at 11:11