title: Combining Restrictions and Projections on DetachedCriteria
body: <p>I have  problem with combining Restrictions and  Projections on DetachedCriteria.
  If I use only Restriction or Projections separately the program works.
  How can I combine those two together? </p>
  
  <p>I have following sql: </p>
  
  <pre><code> select cTopic.topic ,SUM(cTopic.records) as records 
   from Topics cTopic 
   where cTopic.id=? and cTopic.active =? 
   GROUP BY cTopic.topic 
   order by cTopic.orderTopics
  </code></pre>
  
  <p>The following Java codes work fine without using group by (setProjection)</p>
  
  <pre><code>DetachedCriteria criteria = DetachedCriteria.forClass(Coursetopics.class);
  criteria.add(Restrictions.eq("active","Y"));
  criteria.add(Restrictions.eq("id.courseid",Id)));
  
  List&lt;Coursetopics&gt; sumList =  (List&lt;Coursetopics&gt;) hibernateTemplate
                                        .findByCriteria(criteria);    
  </code></pre>
  
  <p>if I add following line of code before last line(List) the program does not work properly.</p>
  
  <pre><code>criteria.setProjection(Projections.projectionList()
                          .add( Projections.sum("records"))
                          .add( Projections.groupProperty("topic") ));
  </code></pre>