title: JPA SUM returns long
body: <p>I am using JPA  and I have the following query </p>
  
  <pre><code>@Query(value = "SELECT  NEW com.example.model.company (
   SUM (CASE WHEN c.company_description_id = 3 THEN  CAST (c.value AS int) ELSE 0 END )
   FROM Company c 
   GROUP BY c.company_id ")
  </code></pre>
  
  <p>c.value is stored as INT in the database, but JPA returns it as long which is wrong. Any ideas what I am doing wrong here. I just want to return the exact value that is stored in the database. It is a simplified version of my query.</p>