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 = false)
public BigDecimal getWeight() {
return weight;
}
For a particular record for which the value of the column is 0.493 I get a BigDecimal whose value is 0.49299999999. It seems that somewhere there is a loss of precision due (maybe) to a Double or Float conversion, but I couldn't track it down with a simple unit test like this:
Double d = new Double("0.493");
System.out.println((d));
Any variant of that code, using Float, BigDecimal and various constructors gives the same result: "0.493"... Any hint on how should I map the column to avoid such issues? I'm using Hibernate 3.5.6, with JPA annotations and Hibernate API (that is Session and not EntityManager)