title: How to group by result with JPA and JpaSpecificationExecutor?
body: <p>I'm using JpaSpecificationExecutor, JPA 2.0, Hibernate and MSSQL and want to build the following query with CriteriaBuilder:</p>
  
  <pre><code>SELECT CURR_DATE, MAX(POSITION) FROM TOP_COMPONENT_HISTORY GROUP BY CURR_DATE
  </code></pre>
  
  <p>My Question: Possible? And if, how?</p>
  
  <p>Thanks for wrapping your mind around this!</p>
  
  <p>This is my code..</p>
  
  <p>Table (TOP_COMPONENT_HISTORY)</p>
  
  <pre><code>1   ARC_ID  varchar NO          
  2   CURR_DATE   varchar NO          
  3   REG_DATE    datetime2   YES         7
  4   APPLY_DATE  datetime2   YES         7
  5   POSITION    int YES 10  0   
  6   REG_USER_ID varchar NO          
  7   MOD_USER_ID varchar NO  
  </code></pre>
  
  <p>Service</p>
  
  <pre><code>public Page&lt;TopComponentHistory&gt; findByCurrDate(ArticleSearchForm searchForm){
          return topComponentHistoryRepository.findAll(TopComponentHistory.findAllGroupBy(),constructPageSpecification(searchForm.getPageNum());
      }
  </code></pre>
  
  <p>Domain</p>
  
  <pre><code>public class TopComponentHistory implements Serializable {
      public static Specification&lt;TopComponentHistory&gt; findAllGroupBy() {     
         How can i make query...
         return ..
      }
  }
  </code></pre>
  
  <p>Repository</p>
  
  <pre><code>public interface TopComponentHistoryRepository extends JpaRepository&lt;TopComponentHistory, String&gt;, JpaSpecificationExecutor&lt;TopComponentHistory&gt; {
  
  
  }
  </code></pre>