title: SAP olingo-jpa-processor-v4 : $count function is not working with with MS SQL server
body: <p><strong>API</strong></p>
  <p>http://localhost:8091/v1/Orders/$count</p>
  <p>http://localhost:8091/v1/Orders?$count=true</p>
  <p><strong>Error:</strong></p>
  <pre><code>{
      &quot;error&quot;: {
          &quot;code&quot;: null,
          &quot;message&quot;: &quot;class java.lang.Integer cannot be cast to class java.lang.Long&quot;
         }
  }
  </code></pre>
  <p>In MS SQL server, the return type of the count function is int.</p>
  <p><a href="https://i.stack.imgur.com/LTV95.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LTV95.png" alt="enter image description here" /></a></p>
  <p>JPAJoinQuery.java &gt; CountResults() method will be called in case of /orders/$count or /orders?$count=true.
  This calls getSingleResult() (line no: 104). So, expected return type is Long.</p>
  <p><a href="https://i.stack.imgur.com/F9hLD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F9hLD.png" alt="enter image description here" /></a></p>
  <p>TypeQueryImpl.java &gt; getSingleResult() calls getResultList()(line no: 185), which returns List instead of List&lt;Long)</p>
  <p><a href="https://i.stack.imgur.com/8vsqN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8vsqN.png" alt="enter image description here" /></a></p>
  <p>because the select count() query returns List.
  <a href="https://i.stack.imgur.com/eMt8r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eMt8r.png" alt="enter image description here" /></a></p>
  <p>Can somebody help here.</p>