title: Implicitly casting bigint postgres datatytpe to Java Long
body: <p>I am using a native Query to obtain a list of <code>bigint</code> numbers which I then plan to iterate.</p>
  
  <pre><code>@Query(value="SELECT bigint_field FROM complex_innerquery", nativeQuery=true)
  Collection&lt;Long&gt; getAllBigIntFieldValues();
  </code></pre>
  
  <p>If I use the Long datatype as shown above, it throws the following error</p>
  
  <blockquote>
    <p>java.math.BigInteger cannot be cast to java.lang.Long</p>
  </blockquote>
  
  <p>It seems like JPA converts bigint from database into BigInteger by default.</p>
  
  <p>Clearly, BigInteger is a giant datatype compared to Long. Although, while storing, my field is of type Long in the entity defined and therefore, there is no chance of losing data while doing the conversion from BigInteger back to Long value, is there any other way by which I can get rid of BigInteger datatype? More specifically, I don't want the methods calling <code>getAllBigIntFieldValues</code> method to explicitly convert BigInteger to LongValue.</p>