Issue Details (XML | Word | Printable)

Key: DBUTILS-1
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Xinyi-Huang(???)
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons DbUtils

[dbutils] BeanListHandler and BeanHandler fail to support java.sql.Date()

Created: 14/Mar/06 10:23 PM   Updated: 02/Jan/08 07:29 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works patch-DBUTILS-1-and-3.txt 2006-11-01 04:03 PM Alan B. Canon 1.0 kB
Text File Licensed for inclusion in ASF works Proposed-DBUTILS-1.patch 2006-11-02 06:17 AM Henri Yandell 1 kB
Environment:
Operating System: Windows 2000
Platform: PC

Bugzilla Id: 38963
Resolution Date: 03/Nov/06 05:03 PM


 Description  « Hide
BeanListHandler or BeanHandler fail to support the java.sql.Date type when
read from database.
I just add some codes to callSetter the method callSetter of BeanProcessor as
----------------------
else if(params[0].getName().equals("java.sql.Date")){
value = (value==null)?null:new java.sql.Date
(((java.util.Date)value).getTime());
setter.invoke(target, new Object[] {value});
----------------------


org.apache.commons.dbutils.BeanProcessor

private void callSetter(Object target, PropertyDescriptor prop, Object value)
throws SQLException {

Method setter = prop.getWriteMethod();

if (setter == null) { return; }

Class[] params = setter.getParameterTypes();
try {
// Don't call setter if the value object isn't the right type
if (this.isCompatibleType(value, params[0])) {
setter.invoke(target, new Object[] { value });
}else if(params[0].getName().equals("java.sql.Date")){
value = (value==null)?null:new java.sql.Date
(((java.util.Date)value).getTime());
setter.invoke(target, new Object[] {value});
}

} catch (IllegalArgumentException e) { throw new SQLException( "Cannot set " + prop.getName() + ": " + e.getMessage()); } catch (IllegalAccessException e) { throw new SQLException( "Cannot set " + prop.getName() + ": " + e.getMessage()); } catch (InvocationTargetException e) { throw new SQLException( "Cannot set " + prop.getName() + ": " + e.getMessage()); }
}



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henri Yandell made changes - 16/May/06 10:06 AM
Field Original Value New Value
issue.field.bugzillaimportkey 38963 12342977
Henri Yandell made changes - 16/May/06 11:29 AM
Component/s DbUtils [ 12311110 ]
Affects Version/s 1.1.0 [ 12311676 ]
Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
Key COM-2825 DBUTILS-1
Project Commons [ 12310458 ] Commons DbUtils [ 12310470 ]
Henri Yandell made changes - 16/May/06 12:04 PM
Affects Version/s 1.1.0 [ 12311715 ]
Henri Yandell made changes - 19/Jul/06 06:23 AM
Fix Version/s 1.1 [ 12311973 ]
Bugzilla Id 38963
Alan B. Canon made changes - 01/Nov/06 04:03 PM
Attachment patch-DBUTILS-1-and-3.txt [ 12344111 ]
Henri Yandell made changes - 02/Nov/06 06:17 AM
Attachment Proposed-DBUTILS-1.patch [ 12344155 ]
Henri Yandell made changes - 03/Nov/06 05:03 PM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Henri Yandell made changes - 02/Jan/08 07:29 AM
Status Resolved [ 5 ] Closed [ 6 ]