I am using a native Query to obtain a list of bigint numbers which I then plan to iterate.
@Query(value="SELECT bigint_field FROM complex_innerquery", nativeQuery=true)
Collection<Long> getAllBigIntFieldValues();
If I use the Long datatype as shown above, it throws the following error
java.math.BigInteger cannot be cast to java.lang.Long
It seems like JPA converts bigint from database into BigInteger by default.
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 getAllBigIntFieldValues method to explicitly convert BigInteger to LongValue.