title: Hibernate criteria Using GROUP BY and RETURN ENTITY LIST
body: <p>I'm trying to use <code>GROUP BY</code> in my criteria. I need to do this:</p>
  
  <pre><code>SELECT b FROM Book b GROUP BY volumeCode;
  </code></pre>
  
  <p>I have following code:</p>
  
  <pre><code>    Criteria c = s.createCriteria(Book.class);
      c.setProjection(Projections.projectionList().add(Projections.groupProperty("volumeCode")));
      List&lt;Book&gt; result = c.list();
  </code></pre>
  
  <p>But this criteria returns only <code>volumeCode</code>s (a list of Strings). I need to get a list of <code>Book</code>s. So I tried to use Transformers:</p>
  
  <pre><code>    Criteria c = s.createCriteria(Book.class);
      c.setProjection(Projections.projectionList().add(Projections.groupProperty("volumeCode")));
      c.setResultTransformer(Transformers.aliasToBean(Book.class));
      List&lt;Book&gt; result = c.list();
  </code></pre>
  
  <p>This code returns list of null values. Is it possible to do that with criteria?</p>