Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal

Поиск
Список
Период
Сортировка
От Francisco Olarte
Тема Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal
Дата
Msg-id CA+bJJbzxY_BPqw_JD1cb+DEJhL2O8XEyBs0Z_M7668cFCJ3gHg@mail.gmail.com
обсуждение исходный текст
Ответ на Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal  (Vinodh NV <linktovinodh@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: rob stone
Дата:
Сообщение: Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal
Следующее
От: Francisco Olarte
Дата:
Сообщение: Re: Require assistance in Postgres + Hibernate : Error:java.math.BigInteger cannot be cast to java.math.BigDecimal