Vinodh:

On Tue, Feb 13, 2018 at 9:58 AM, Vinodh NV <linktovin...@gmail.com> wrote:
> Require assistance on the below:
> Code snippet:
> Map<String,Object> ic;
> //Populate values for ic
> long count = ((BigDecimal)ic.get(“EB”)).longValue();
>
>
> Getting the below error:
>     java.math.BigInteger cannot be cast to java.math.BigDecimal
>     ®java.lang.ClassCastException: java.math.BigInteger cannot be cast to
> java.math.BigDecimal
>
> Since this is not part of a query doing select cast (EB as bigint) will not
> help in this case:

I do not know hibernate, so Ihaven't the sligstest idea of why
get("EB") returns BigInteger or why you do not cast it to BigInteger
instead of BigDecimal.

But if your problem is it sometimes has Bigdecimal and sometimes
BigInteger you could try casting it to the parent, Number, which is
the one specifying longValue() and would make the code work with both.



Francisco Olarte.

Reply via email to