Java.math.BigInteger cannot be passed to java.math.BigDecimal

We are moving from Oracle to PostgreSQL. Some Oracle-specific queries had to be changed to Postgres equivalents. The following is one such commit:

At first

Query query = getEntityManager().createNativeQuery("SELECT PC_SITE_GROUP_ID_SEQ.NEXTVAL from DUAL");
BigDecimal result = (BigDecimal) query.getSingleResult();

has been changed to,

Query query = getEntityManager().createNativeQuery("SELECT NEXTVAL('pc_site_group_id_seq')");
BigDecimal result = (BigDecimal) query.getSingleResult();

When starting after the change, it launched an error,

java.math.BigInteger cannot be passed to java.math.BigDecimal

My question is, why did it work before? Recall that the first change was made to the Oracle database, and the second to the Postgres database. Please, help.

+4
source share
1 answer

The Oracle database does not have an “integer” data type, so everything is displayed by the BigDecimal driver.

Postgres ( bigint) , BigInteger bigint.

bigint, BigInteger.

+3

Source: https://habr.com/ru/post/1692571/


All Articles