db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r366015 - /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
Date Wed, 04 Jan 2006 23:06:58 GMT
Author: tomdz
Date: Wed Jan  4 15:06:55 2006
New Revision: 366015

URL: http://svn.apache.org/viewcvs?rev=366015&view=rev
Log:
Added fix for BigDecimal values that are inserted into the database because Statement.setObject(index/name,object,datatype)
uses a scale value of 0 for NUMERIC/DECIMAL columns; therefore the setBigDecimal method is
now used instead

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=366015&r1=366014&r2=366015&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Wed Jan
 4 15:06:55 2006
@@ -664,7 +664,17 @@
 
             for (Iterator iter = parameters.iterator(); iter.hasNext(); paramIdx++)
             {
-                statement.setObject(paramIdx, iter.next());
+                Object arg = iter.next();
+
+                if (arg instanceof BigDecimal)
+                {
+                    // to avoid scale problems because setObject assumes a scale of 0
+                    statement.setBigDecimal(paramIdx, (BigDecimal)arg);
+                }
+                else
+                {
+                    statement.setObject(paramIdx, arg);
+                }
             }
             resultSet = statement.executeQuery();
             answer    = createResultSetIterator(model, resultSet, queryHints);
@@ -787,7 +797,17 @@
 
             for (Iterator iter = parameters.iterator(); iter.hasNext(); paramIdx++)
             {
-                statement.setObject(paramIdx, iter.next());
+                Object arg = iter.next();
+
+                if (arg instanceof BigDecimal)
+                {
+                    // to avoid scale problems because setObject assumes a scale of 0
+                    statement.setBigDecimal(paramIdx, (BigDecimal)arg);
+                }
+                else
+                {
+                    statement.setObject(paramIdx, arg);
+                }
             }
             resultSet = statement.executeQuery();
 
@@ -1523,7 +1543,7 @@
         }
         else if (value instanceof BigDecimal)
         {
-            // Derby doesn't like BigDecimal's in setObject
+            // setObject assumes a scale of 0, so we rather use the typed setter
             statement.setBigDecimal(sqlIndex, (BigDecimal)value);
         }
         else if (value instanceof Float)



Mime
View raw message