Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal - Mailing list pgsql-general

From Francisco Olarte
Subject Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal
Date
Msg-id CA+bJJbzxY_BPqw_JD1cb+DEJhL2O8XEyBs0Z_M7668cFCJ3gHg@mail.gmail.com
Whole thread Raw
In response to Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal  (Vinodh NV <linktovinodh@gmail.com>)
List pgsql-general
Vinodh:

On Tue, Feb 13, 2018 at 9:58 AM, Vinodh NV <linktovinodh@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.


pgsql-general by date:

Previous
From: rob stone
Date:
Subject: Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal
Next
From: Francisco Olarte
Date:
Subject: Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal