We are migrating from Oracle to PostgreSQL. Some queries that were specific to Oracle had to be changed to Postgres equivalents. Following is one such commit:
Initially,
Query query = getEntityManager().createNativeQuery("SELECT PC_SITE_GROUP_ID_SEQ.NEXTVAL from DUAL");
BigDecimal result = (BigDecimal) query.getSingleResult();
was changed to,
Query query = getEntityManager().createNativeQuery("SELECT NEXTVAL('pc_site_group_id_seq')");
BigDecimal result = (BigDecimal) query.getSingleResult();
On running, after the change, it threw error,
java.math.BigInteger cannot be cast to java.math.BigDecimal
My question is why it was working before? Just a reminder, the first change was run on Oracle database while the second one on Postgres database. Please help.
BigDecimal. What does that "DUAL" mean here? How did you define your sequence? Could it be a floating/fixed point number in the Oracle case?