これを試して:
Criteria criteriaPurchaseRequest=this.session.createCriteria(PurchaseRequest.class);
ProjectionList projectionList = Projections.projectionList();
projectionList.add(Projections.groupProperty("current_state"));
projectionList.add(Projections.rowCount());
criteriaPurchaseRequest.setProjection(projectionList);
List results = criteriaPurchaseRequest.list();
結果を取得するには:
List results = criteriaPurchaseRequest.list();
Map currentStateMap = new HashMap();
Iterator it=results.iterator();
while (it.hasNext()){
Object obj[]=(Object[])it.next();
CurrentState currentState = (CurrentState )obj[0];
currentStateMap .put(currentState.getDescription().toLowerCase(), (Integer)obj[1]);
}
ここで、CurrentState は列 current_state を表すオブジェクトです (Hibernate はオブジェクトを操作していることを思い出してください)。