title: Hibernate HQL Count Distinct not working?
body: <p>I have the following classes: </p>
  
  <pre><code>class User {
    hasMany = [ratings: Rating] 
  } 
  
  class Item {
   hasMany = [ratings: Rating]
  }
  
  class Rating {
   belongsTo = [user: User, item: Item]
  }
  </code></pre>
  
  <p>I want to count the distinct users that rated on an item.</p>
  
  <p>The following does not work: </p>
  
  <pre><code>select count(distinct(r.user)) from Rating as r
          where r.item=:item
          group by r.user
  </code></pre>
  
  <p><strong>How do I have to modify the HQL query to make it work?</strong></p>