[ http://issues.apache.org/jira/browse/DBUTILS-1?page=all ]
Alan B. Canon updated DBUTILS-1: -------------------------------- Attachment: patch-DBUTILS-1-and-3.txt This patch also addresses DBUTILS-3. It may not work if the patch recently attached to that issue has already been applied to source. > [dbutils] BeanListHandler and BeanHandler fail to support java.sql.Date() > ------------------------------------------------------------------------- > > Key: DBUTILS-1 > URL: http://issues.apache.org/jira/browse/DBUTILS-1 > Project: Commons DbUtils > Issue Type: Bug > Environment: Operating System: Windows 2000 > Platform: PC > Reporter: Xinyi-Huang > Fix For: 1.1 > > Attachments: patch-DBUTILS-1-and-3.txt > > > 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()); > } > } -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]