title: JpaSpecificationExecutor : complex queries with specifications
body: <p>I'm actually creating research with different filters.</p>
  
  <p>As I'm using the JpaRepository to make simple queries, I found the JpaSpecificationExecutor to make dynamic queries with the Criterias.</p>
  
  <p>My problem is I need to create a complex query with a group by and a count().
  It's ok for the group by but I don't find how I can overide the "select" part to put a "count" instruction.</p>
  
  <p>Does anybody can help me please ?</p>
  
  <p>I'm using spring 3.1.2 and spring-jpa-data 1.0.3
  Here is my code :</p>
  
  <pre><code>return new Specification&lt; Article &gt;() {
  
      @Override
      public Predicate toPredicate(final Root&lt;Article&gt; root,
          final CriteriaQuery&lt;?&gt; query, final CriteriaBuilder builder) {
          //count ???
          query.groupBy(root.get(Article_.id));
          Predicate p = builder.and(builder.like(root.&lt;String&gt; get(Article_.title), "%" + title + "%"));
  
          return p;
      }
  }
  </code></pre>
  
  <p>Thanks !</p>