db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toby cabot <t...@caboteria.org>
Subject [patch] add decimal precision to JDBC ant task
Date Wed, 27 Aug 2003 15:34:40 GMT
Hi,

The Torque generator JDBC ant task works very well.  Thank you!

When I ran it against an Oracle database all numeric types ended up
looking like:

        <column name="MY_NUMBER" size="15" type="DECIMAL"/>

... which is OK but didn't let me tell whether the number had any
fractional part, so I added some code to add a "decimalDigits"
attribute to the output, e.g.

        <column decimalDigits="4" name="MY_NUMBER" size="15" type="DECIMAL"/>

Regards,
Toby Cabot

Here's the patch:

Index: src/java/org/apache/torque/task/TorqueJDBCTransformTask.java
===================================================================
RCS file: /home/cvspublic/jakarta-turbine-torque/src/generator/src/java/org/apache/torque/task/TorqueJDBCTransformTask.java,v
retrieving revision 1.6
diff -u -r1.6 TorqueJDBCTransformTask.java
--- src/java/org/apache/torque/task/TorqueJDBCTransformTask.java        22 Aug 2003 17:01:42
-0000      1.6
+++ src/java/org/apache/torque/task/TorqueJDBCTransformTask.java        27 Aug 2003 15:38:21
-0000
@@ -290,6 +290,7 @@
                 String name = (String) col.get(0);
                 Integer type = ((Integer) col.get(1));
                 int size = ((Integer) col.get(2)).intValue();
+                Integer decimalDigits = ((Integer) col.get(5));
 
                 // From DatabaseMetaData.java
                 //
@@ -349,6 +350,12 @@
 
                     column.setAttribute("default", defValue);
                 }
+
+                if (decimalDigits != null && decimalDigits.intValue() > 0)
+                {
+                    column.setAttribute("decimalDigits", String.valueOf(decimalDigits.intValue()));
+                }
+
                 table.appendChild(column);
             }
 
@@ -439,15 +446,17 @@
                 String name = columnSet.getString(4);
                 Integer sqlType = new Integer(columnSet.getString(5));
                 Integer size = new Integer(columnSet.getInt(7));
+                Integer decimalDigits = new Integer(columnSet.getInt(9));
                 Integer nullType = new Integer(columnSet.getInt(11));
                 String defValue = columnSet.getString(13);
 
-                List col = new ArrayList(5);
+                List col = new ArrayList(6);
                 col.add(name);
                 col.add(sqlType);
                 col.add(size);
                 col.add(nullType);
                 col.add(defValue);
+                col.add(decimalDigits);
                 columns.add(col);
             }
         }

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message