title: how can I get custom data group by enum property with JPQL or Criteria Api in spring data?
body: <p>I have an enumeration to store Currencies : </p>
  
  <pre><code>public enum Currency {
  
      USD,EUR,GBP
  
  }
  </code></pre>
  
  <p>And I have Sales entity that contain currency as a property: </p>
  
  <pre><code>public class Sales {
  
      private Long id;
      private Merchant merchant;
      private Customer customer;
      private double amount;
      private Currency currency;
  
  }
  </code></pre>
  
  <p>sample table data for sales is like below : </p>
  
  <pre><code>+----+-------------+-------------+--------+----------+
  | id | merchant_id | customer_id | amount | currency |
  +----+-------------+-------------+--------+----------+
  |  1 |           2 |           3 |  125.0 | EUR      |
  |  2 |           1 |           2 |  135.0 | USD      |
  |  3 |           3 |           5 |  140.0 | GBP      |
  |  4 |           2 |           8 |   25.0 | USD      |
  |  5 |           4 |           8 |   95.0 | EUR      |
  |  6 |           6 |           9 |   85.0 | EUR      |
  |  7 |           5 |           6 |   90.0 | USD      |
  |  8 |           1 |           1 |  225.0 | EUR      |
  |  9 |           7 |           2 |  350.0 | GBP      |
  |  . |           . |           . |      . | .        |
  |  . |           . |           . |      . | .        |
  |  . |           . |           . |      . | .        |
  |  . |           . |           . |      . | .        |
  +----+-------------+-------------+--------+----------+
  </code></pre>
  
  <p>this is my custom data model </p>
  
  <pre><code>    public class CustomDataModel{
  
        private Integer count; //record count
        private double total; // its total amount for specified currency 
        private Currency currency; //  it also could be String, it is doesn't matter  
  
  }
  </code></pre>
  
  <p>My query params: <strong>merchant_id</strong> and <strong>customer_id</strong>.</p>
  
  <p>I want to get result as <strong><code>List&lt;CustomDataModel&gt;</code></strong>  for example : </p>
  
  <pre><code>[  
     {  
        "count":5,
        "total":674.00,
        "currency":"USD"
     },
     {  
        "count":3,
        "total":561.00,
        "currency":"EUR"
     },
     {  
        "count":4,
        "total":715.00,
        "currency":"GBP"
     }
  ]
  </code></pre>
  
  <p>is it possible to get result like this. If it is how can i do it?</p>