ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Prashanth Sukumaran <prashanthsukuma...@yahoo.com>
Subject Re: QueryForObject returns wrong data
Date Wed, 27 Jul 2005 22:58:56 GMT
Hi Jeff,

I don't know how the scale would work.

As per jdk 1.4 there are 4 constructors to create BigDecimal.  The first two use biginteger,
i
think this will not be a case at BigInteger would not be mapped to Decimal type field.

The other two use double or string.  In both cases the value is 90.94.

		BigDecimal bd = new BigDecimal("90.94");
		double dble = 90.94;
		BigDecimal bd2 = new BigDecimal(dble);
		System.out.println("The big decimal value is "+bd);
		System.out.println("The big decimal integer value is "+bd2);


The big decimal value is 90.94
The big decimal integer value is 90.93999999999999772626324556767940521240234375

i tried setting the scale for example 

		bd.setScale(1);

Ofcourse there are two decimals but i tried with setScale(1) you would get a 
   java.lang.ArithmeticException: Rounding necessary
	at java.math.BigDecimal.divide(BigDecimal.java:465)
	at java.math.BigDecimal.setScale(BigDecimal.java:699)


with setScale(2).  Java gives the output as 90.94 which is same without scale.

Shilpa are you sure there is no typo or some problem in the data flow.  Are you coping data
from
one bean to another.  Just for kicks why don't you create another field which is a varchar
have
the data as string 90.94 and in the result map have javaType as BigDecimal and dataType as
Varchar.

Also paste the java bean code here and the dao class code that is calling it?

Rgds

Prashanth.



--- Jeff Butler <dhscn06@cstone.dhs.state.il.us> wrote:

> Shilpa,
> 
> I cannot get this to fail using DB2 version 8.2, fixpack 9a.  I have
> used both the type 2 and type 4 drivers, and I get the correct results
> in each case (even calling the SP multiple times - works every time).
> 
> I still believe this is something that should be changed in iBATIS -
> just to make sure we are following the JDBC spec as closely as possible.
>  But it looks like the DB2 version 8 drivers are fairly robust.
> 
> Would you please provide some configuration details:
> 
> 1. DB2 Server Version and platform
> 2. DB2 Client Version
> 3. Type of driver you are using
> 
> I don't have easy access to DB2 version 7 anymore for testing, but that
> might be part of the problem if you are still on that version.  The
> version 7 driver had some, shall we say, peculiarities.
> 
> Jeff Butler
> 
> 



		
____________________________________________________
Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

Mime
View raw message