Cast bigint to long Cast bigint to long database database

Cast bigint to long


have you tried casting your value to BigInteger first and then get the long value with longValue()? It should work. And aioobe is right, check for null values also.

cheers!


I was getting error java.math.BigInteger cannot be cast to java.lang.Long because I was getting the BigInteger while querying using Spring Data native query, so then I've resolved using below code.

((BigInteger)nativeQuery.getSingleResult()).longValue()