title: count with other fields in group by with hibernate
body: <p>I want to return <strong>count</strong> of rows with some other fields in a group by with hibernate, and i have not any field in my entity class representing count. for example i have a Payment entity class:</p>
  
  <pre><code>class Payment
  {
      private Long id;
      private String totalCode;
      private String activityCode;
      private Long amount;
  
      // other fields and setter/getters
  }
  </code></pre>
  
  <p>sql query:</p>
  
  <pre><code>select count(*), sum(p.amount), p.total_code, p.activity_code 
  from  tb_payment p
  group by p.total_code,p.activity_code
  </code></pre>
  
  <p>and my hibernate criteria:</p>
  
  <pre><code>Session session = getCurrentSession();
  ProjectionList projectionList = Projections.projectionList();        
  projectionList.add(Projections.groupProperty("totalCode"))
          .add(Projections.groupProperty("activityCode"))
          .add(Projections.sum("amount"))
          .add(Projections.count("id"));
  Criteria criteria  = session.createCriteria(Payment.class);
  criteria.setProjection(projectionList);
  List&lt;Payment&gt; payments = criteria.list();
  </code></pre>
  
  <p>As i said, my problem is i don't know where/how can i access the value of count (from criteria.list())!?</p>