DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24264>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24264

JDBCDynaClass should support column label.

           Summary: JDBCDynaClass should support column label.
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Bean Utilities
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


JDBCDynaClass should support column label, not just using the column name as 
the DynaProperty name.  Currently if you joing two tables and the two tables 
have the same column name, then the current implementation fails.  The fix is 
included below




Index: JDBCDynaClass.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/beanutils/src/java/org/apache/commons/beanutils/JDBCDynaClass.java,v
retrieving revision 1.3
diff -u -r1.3 JDBCDynaClass.java
--- JDBCDynaClass.java  9 Oct 2003 20:43:15 -0000       1.3
+++ JDBCDynaClass.java  30 Oct 2003 18:53:27 -0000

@@ -87,6 +91,13 @@
      */
     protected boolean lowerCase = true;

+       /**
+        * <p>Flag defining whether column names should be the column name
+        * or the column label.</p>
+        */
+        protected boolean useName = true;
+
+
     /**
      * <p>The set of dynamic properties that are part of this
      * [EMAIL PROTECTED] DynaClass}.</p>
@@ -199,12 +210,12 @@
                                     int i)
                                     throws SQLException {

-        String name = null;
+        String name = ( useName ) ? metadata.getColumnName(i) : 
metadata.getColumnLabel(i);
+
         if (lowerCase) {
-            name = metadata.getColumnName(i).toLowerCase();
-        } else {
-            name = metadata.getColumnName(i);
+                  name = name.toLowerCase();
         }
+
         String className = null;
         try {
             className = metadata.getColumnClassName(i);





Index: ResultSetDynaClass.java
===================================================================
RCS file: /home/cvspublic/jakarta-
commons/beanutils/src/java/org/apache/commons/beanutils/ResultSetDynaClass.java,
v
retrieving revision 1.13
diff -u -r1.13 ResultSetDynaClass.java
--- ResultSetDynaClass.java     9 Oct 2003 20:43:15 -0000       1.13
+++ ResultSetDynaClass.java     30 Oct 2003 18:53:54 -0000

 /**
  * <p>Implementation of <code>DynaClass</code> for DynaBeans that wrap the
@@ -146,7 +149,7 @@
      */
     public ResultSetDynaClass(ResultSet resultSet) throws SQLException {

-        this(resultSet, true);
+        this(resultSet, true, false);

     }

@@ -166,13 +169,14 @@
      *
      * @param resultSet The result set to be wrapped
      * @param lowerCase Should property names be lower cased?
-     *
+     * @param useName   Should property names b ethe column name of the
+     *                  label name?
      * @exception NullPointerException if <code>resultSet</code>
      *  is <code>null</code>
      * @exception SQLException if the metadata for this result set
      *  cannot be introspected
      */
-    public ResultSetDynaClass(ResultSet resultSet, boolean lowerCase)
+    public ResultSetDynaClass(ResultSet resultSet, boolean lowerCase, boolean 
useName)
         throws SQLException {

         if (resultSet == null) {
@@ -180,6 +184,7 @@
         }
         this.resultSet = resultSet;
         this.lowerCase = lowerCase;
+        this.useName = useName;
         introspect(resultSet);

     }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to