title: Projections.countDistinct with Hibernate produces unexpected result
body: <p>I have the following code</p>
  
  <pre><code>
  Criteria criteria = this.getCriteriaForClass(DeviceListItem.class);
  Projection rowCountProjection = Projections.countDistinct("color");
  criteria.setProjection(rowCountProjection);
  int rowCount = ((Long) criteria.uniqueResult()).intValue();
  return rowCount;
  </code></pre>
  
  <p>, whose purpose is to find out the number of rows with different values for the field named "color". The problem is that </p>
  
  <pre><code>
  Projections.countDistinct("color");
  </code></pre>
  
  <p>returns the same number of results as </p>
  
  <pre><code>
  Projections.count("color");
  </code></pre>
  
  <p>even though there are multiple rows with same color in the database view. When converting the Criteria object to SQL, I see that the SQL produced by Hibernate is</p>
  
  <pre><code>
  select count(this_.COLOR) as y0_ from DEVICESLIST_VIEW this_ where 1=1
  </code></pre>
  
  <p>when I would expect it to be </p>
  
  <pre><code>
  select count(distinct this_.COLOR) as y0_ from DEVICESLIST_VIEW this_ where 1=1
  </code></pre>
  
  <p>Why doesn't it work like expected and is there some remedy? Unfortunately I have no option to use HQL in this case.</p>