I use the javax.persistence API and Hibernate to create annotations and persistent entities and their attributes in an Oracle 11g Express database.
I have the following attribute in essence:
@Column(precision = 12, scale = 9) private BigDecimal weightedScore;
The goal is to store a decimal value with a maximum of 12 digits and no more than 9 of these digits to the right of the decimal point.
After calculating weightedScore result is 0.1234, but as soon as I pass the object with the Oracle database, the value will be displayed as 0.12.
I can see this by using the EntityManager object to request a record or view it directly in the Oracle Application Express (Apex) interface in a web browser.
How do I annotate my BigDecimal attribute so that accuracy is maintained correctly?
Note. We use the in-memory HSQL database to run our unit tests and do not experience problems with lack of accuracy with or without @Column annotation.
Update:
When looking at the table description, the definition of the column weightedScore NUMBER(19, 2) . I also tried changing the annotation to @Column(columnDefinition="Number(12, 9)") , but this did not affect. Does anyone know why Oracle is not responding to these annotations?
precision oracle11g hibernate jpa bigdecimal
David Kaczynski
source share