-
1. Re: double bean member getting rounded in sybase?
jamesduplain Oct 19, 2001 3:31 PM (in response to jamesduplain)Just tried it with a Double instead of double and had the same problem.
-
2. Re: double bean member getting rounded in sybase?
davidjencks Oct 19, 2001 10:43 PM (in response to jamesduplain)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.
-
3. Re: double bean member getting rounded in sybase?
rgucci May 26, 2003 5:30 AM (in response to jamesduplain)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
<cmp-field>
<field-name>homeAmt</field-name>
<column-name>home_amt</column-name>
<java-type>java.math.BigDecimal</java-type>
<jdbc-type>DECIMAL</jdbc-type>
<sql-type>NUMERIC(18,4)</sql-type>
</cmp-field>
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.