Description
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
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); ... ... ... }
It should be like following
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); } ... ... ...
Let me know if this is not how it suppose to be or I am missing something here.
Thanks,
Viral Patel
Attachments
Attachments
Issue Links
- is related to
-
BEANUTILS-383 `select name as foo_name' - > RowSetDynaClass detects false column name which causes java.sql.SQLException: Column 'name' not found.
- Open
-
BEANUTILS-355 JDBCDynaClass should still support column label
- Closed
- relates to
-
BEANUTILS-371 RowSetDynaClass.setUseColumnLabel() property setter is useless: the "use column label" flag must be known at construction time
- Closed