groupProperty(String propertyName)
引數說明:Criteria criteria = session.createCriteria(UserForm.class); //獲取Criteria物件 criteria.setProjection(Projections.projectionList() //設定投影查詢列 .add(Projections.groupProperty("username")) .add(Projections.rowCount(),"count")); //設定新增分組的屬性列 list = criteria.list(); //執行查詢語句,獲取查詢結果集 Iterator it = list.iterator(); //獲取查詢疊代器 while(it.hasNext()){ //迴圈遍歷疊代器 Object[] o = (Object[])it.next(); System.out.println("使用者名稱:"+o[0]+"人數:"+o[1]); }