BigDecimal not saved correctly in DB using JPA

I am using JPA with hibernate and Oracle DB (oracle 11.2 xe). I am trying to save a large number, but what is stored in the database is not a large number that I entered.

I have a column where I want to store a large decimal number, displayed as follows:

@Column(name = "INVOICE_AMOUNT", precision = 25, scale = 2, nullable = false) private BigDecimal amount; 

In the database, the column was created as follows:

 INVOICE_AMOUNT NUMBER(25,2) DEFAULT 0 NOT NULL, 

The problem is that I am trying to save the number "19999979998000000". Just before I do this, I debugged the field, and he said:

 amount = { java.math.BigDecimal@13204 }"1.9999979998E+16" 

But in the database, the value that is stored is 20 ...

Versions:

 jpa 1.0 hibernate-3.2.6.ga.jar jboss-4.2.3.GA 

What am I doing wrong?

+4
source share
1 answer

Updating to version ojdbc14 version 10.2.0.5 solves the problem (I think it was fixed in 10.2.0.4)

+2
source

All Articles