commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Viral (JIRA)" <j...@apache.org>
Subject [jira] Created: (BEANUTILS-344) Method createDynaProperty of JDBCDynaClass should first look for column label instead of column name in ResultSetMetadata object..
Date Sun, 05 Apr 2009 07:07:12 GMT
Method createDynaProperty of JDBCDynaClass should first look for column label instead of column
name in ResultSetMetadata object..
----------------------------------------------------------------------------------------------------------------------------------

                 Key: BEANUTILS-344
                 URL: https://issues.apache.org/jira/browse/BEANUTILS-344
             Project: Commons BeanUtils
          Issue Type: Bug
          Components: DynaBean
    Affects Versions: 1.8.0-BETA
            Reporter: Viral
             Fix For: 1.8.0-BETA


Method  *createDynaProperty( ResultSetMetaData metadata, int i)*  of class *JDBCDynaClass*
should read *column label* instead of *column name* from ResultSetMetadata object.

For example..
If query is something like *'select user_id as userId, user_name as userName....'* than *columName*
variable should have the value *userId* instead of *user_id*

Fix is ..

*Original*
{code:title=JDBCDynaClass.java|borderStyle=solid}
protected DynaProperty createDynaProperty(
                                    ResultSetMetaData metadata,
                                    int i)
                                    throws SQLException {
//This is reading ColumnName but not ColumnLabel which returns value 'user_id' ..not 'userId'

String columnName = metadata.getColumnName(i); 
...
...
...
}
{code} 

*It should be like following*

{code:title=JDBCDynaClass.java|borderStyle=solid}
protected DynaProperty createDynaProperty(
                                    ResultSetMetaData metadata,
                                    int i)
                                    throws SQLException {
 //First read ColumnLabel ..which sould be 'userId' in our case
 String columnName = metadata.getColumnLabel(i);  

 // If ColumnLabel is 'null' or 'empty' read ColumnName...
 if(columnName == null || columnName.trim().equals(""))  {  
     columnName = metadata.getColumnName(i);
 }
...
...
...
{code} 

Let me know if this is not how it suppose to be or I am missing something here.

Thanks,
Viral Patel



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message