title: hibernate select all projections group by
body: <p>In hibernate Criteria specification, if I want to group property in table, I must use Projections.groupProperty.  The problem is I can't select all the field in the table.</p>
  
  <p>What I want to is:</p>
  
  <p>SELECT * FROM entity GROUP BY field</p>
  
  <p>If i use group in hibernate Criteria, then the groupProperty must be exist, and the sql result will be:
  SELECT field FROM entity GROUP BY field.</p>
  
  <p>Is there any way to get what I want?  I see in hibernate code, in CriteriaJoinWalker, when I want to select all (select *), the code is already specify if there is projection or not.  My assumption if I want to change the behavior, I must change the CriteriaJoinWalker code.  I can modify the code, and maybe I can get the result what I want, but if I can, I do not want to override the hibernate core code to my project.  Is there any way to change it directly without change hibernate code?</p>
  
  <pre><code>    // CriteriaJoinWalker
      if(translator.hasProjection())
      {
          resultTypes = translator.getProjectedTypes();
          initProjection(translator.getSelect(), translator.getWhereCondition(), translator.getOrderBy(), translator.getGroupBy(), LockMode.NONE);
      } else
      {
          resultTypes = (new Type[] {
              TypeFactory.manyToOne(persister.getEntityName())
          });
          initAll(translator.getWhereCondition(), translator.getOrderBy(), LockMode.NONE);
      }
  </code></pre>
  
  <p>Thanks</p>