// use hibernate to implement group by and sum and count
session sess = this. getsession (false);
List list = NULL;
If (sess! = NULL) {
Criteria CRI = sess. createcriteria (getmodelclass ();
CRI. add (expression. alleq (props);
// always count id
projectionlist projlist = projections. projectionlist ();
projlist. add (projections. sum (SUM);
projlist. add (projections. groupproperty (group1);
projlist. add (projections. groupproperty (group2);
projlist. add (projections. count (count);
CRI. setprojection (P Rojlist);
List = CRI. List ();
}< br> List = NULL? New arraylist (): List;
return list;
// Use hibernate to implement group by and sum and count
List listbygroupsum = Dao. getlistbygroupsumcp (props );
Iterator iter = listbygroupsum. iterator ();
If (! ITER. hasnext ()){
System. Out. println ("No objects to display .");
}
While (ITER. hasnext ()){
System. Out. println ("new object ");
Object [] OBJ = (object []) ITER. Next ();
For (INT I = 0; I <obj. length; I ++ ){
System. Out. println (OBJ [I]);
}
}