I have this column in my Oracle 11g mapped as NUMBER (21,20), which is mapped in Hibernate as:
@Column(name = \"PESO\", precision = 21, scale = 20, nullable
It's a result of initializing BigDecimal
from double
:
System.out.println(String.format("%21.20f", new BigDecimal(0.493));
// Prints 0,49299999999999999378
So, when BigDecimal
initialized this way is saved in the database, it produces an inaccurate value, which is correctly loaded later.
If BigDecimal
is initialized by string or if the value is set directly in Java everything works fine.