title: how to get distinct results using Projections and Criteria
body: <p>I am trying to load distinct Parents using Criteria in Grails. The query is as following</p>
  
  <p><strong>Query:</strong>      </p>
  
  <pre><code>def criteria = Parent.createCriteria();
          results =  criteria.list(max:params.max, offset:params.offset){
              projections{ groupProperty('id') }
              children{
                  books{
                      like('title',"%book")
                      }
                  }
              order("id","asc")
          }
  </code></pre>
  
  <p><strong>Domain Classes</strong></p>
  
  <pre><code>    class Parent {
  
      String name
  
      static hasMany = [children:Child]
  
      static constraints = {
      }
  }
  
  
  class Child {
  
          String name
          Parent parent
  
          static belongsTo = [parent:Parent]
          static hasMany =   [books:Book]
          static constraints = {
          }
      }
  
  
  class Book {
  
          String title
          Child child
  
          static belongsTo = [child:Child]
          static constraints = {
          }
      }
  </code></pre>
  
  <p><strong>Question</strong> : I am unable to get distinct Parent Rows.</p>
  
  <p><strong>Other adopted Approaches and their results:</strong> I donot know why <em>groupProperty</em> is not working. I have tried  <em>distinct</em> in projections instead of <em>groupProperty</em> and it isnt fruitfull too!. if i use  <em>criteria.listDistinct</em> instead of <em>criteria.list</em> then i am able to get distinct Parent Rows but earlier approach require to get <em>totalCount</em> from extra query for pagination. Therefore i am highly intersted in getting distinct Parent Rows using <em>criteria.list</em></p>
  
  <p>Thanks in advance</p>