Just tried it with a Double instead of double and had the same problem.
Floating point numbers are not exact numerics. I suspect a double 4.5 == 4.49999... in java itself. It certainly cant't be represented exactly. If you want exact decimal calculations use Numeric(x, y) in your db and BigDecimal in java. With luck, your db driver might support this. You can also use int or long and scale it yourself.
We are having a problem with inserting values into a NUMERIC field in Sybase using CMP.
The entity bean's field is defined as BigDecimal.
The Sybase table field is defined as NUMERIC(18,4).
In jaws.xml, a type mapping is defined for the bigdecimal field as
We define the mapping in jaws.xml instead of standardjaws.xml because changing standardjaws doesnt seem to have any effect and still uses the mapping for IMAGE instead of NUMERIC.
When inserting a value with a decimal part, such as new BigDecimal("1234.123"), the value stored in the database is just the integer part (1234).
Are we using the correct type mapping?
JBoss version is 2.4.10.