title: Group by in JPA criteria query
body: <p>I have a table like it:</p>
  
  <pre><code>  id  |  value  |  name
  ------+---------+--------
    1   |    a    | name1  
    2   |    b    | name2  
    3   |    a    | name3  
    4   |    a    | name4  
    5   |    c    | name5 
    6   |    b    | name6  
    7   |    c    | name7  
    8   |    b    | name8    
  </code></pre>
  
  <p>and what I want is:</p>
  
  <pre><code>  id  |  value  |  names
  ------+---------+---------------------------
    1   |    a    | name1 , name3, name4
    2   |    b    | name2 , name6, name8
    3   |    c    | name5 , name7
  </code></pre>
  
  <p>In fact I want to get all records in each group and iterate on these records.
  I tried this code, but it does not works:</p>
  
  <pre><code>javax.persistence.criteria.CriteriaQuery cq = getEntityManager().getCriteriaBuilder().createQuery();
  Root&lt;T&gt; c = cq.from(entityClass);
  
  cq.select(c);
  
  cq.groupBy(c.get("value"));
  javax.persistence.Query q = getEntityManager().createQuery(cq);
  return q.getResultList();
  </code></pre>
  
  <p>thanks.</p>