title: Getting a count of records for the table with hasMany relationship
body: <p>I've got color and shade domains in my grails application. </p>
  
  <pre><code>class Color {
    static hasMany = [shades: Shade]
  }
  
  class Shade {
    static belongsTo = [color: Color]
  }
  </code></pre>
  
  <p>Using criteria, how can I get a list of Colors where there are X shades? where X is a number that I can pass in. </p>
  
  <p>I know that this returns entire list of colors:</p>
  
  <pre><code>def list = Color.createCriteria.listDistinct {
      shade {
         count()
      }
  }
  </code></pre>
  
  <p>but I don't know how to get list where shade count is specific. I tried this but it didnt work. </p>
  
  <pre><code>def list = Color.createCriteria.listDistinct {
      shade {
         count() == 5
      }
  } 
  </code></pre>