I’m wondering if anybody knows how to get multiple counts from a single query using hibernates criteria query?
I have the following query.
List<PurchaseRequest> prs = this.session.createCriteria(PurchaseRequest.class).list();
within PurchaseRequest, I have a column called current_state. I’d like to query all the PurchaseRequest rows and group the current_states together so I can get a total count of each current_state.
States look like this, creator, authorizer, assignor. etc.
Try this:
To obtain the results:
where CurrentState is an object that represents the column current_state (remember, Hibernate is working with objects).