commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carl Hall (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (DBUTILS-121) Allow influencing the setter method used
Date Sat, 03 Jan 2015 02:14:34 GMT

    [ https://issues.apache.org/jira/browse/DBUTILS-121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14220148#comment-14220148
] 

Carl Hall edited comment on DBUTILS-121 at 1/3/15 2:13 AM:
-----------------------------------------------------------

Using the attached patch, my implementation looks like this:

{code}
  protected Method getWriteMethod(Object target, PropertyDescriptor prop, Object value) {
    Method method;
    try {
      method = target.getClass().getMethod(prop.getWriteMethod().getName(), value.getClass());
    } catch (NoSuchMethodException e) {
      method = prop.getWriteMethod();
    }
    return method;
  }
{code}


was (Author: thecarlhall):
Using the attached patch, my implementation looks like this:

{code}
  protected Method findWriteMethod(Object target, PropertyDescriptor prop, Object value) {
    Method method;
    try {
      method = target.getClass().getMethod(prop.getWriteMethod().getName(), value.getClass());
    } catch (NoSuchMethodException e) {
      method = prop.getWriteMethod();
    }
    return method;
  }
{code}

> Allow influencing the setter method used
> ----------------------------------------
>
>                 Key: DBUTILS-121
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-121
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.6
>            Reporter: Carl Hall
>            Assignee: Carl Hall
>             Fix For: 1.7
>
>         Attachments: dbutils-121.patch
>
>
> I have cases where the field in a bean doesn't quite match the column it is stored as.
 e.g. {{Timestamp}} in the database but {{org.joda.DateTime}} in the bean.  It would be nice
to allow the bean processor to have influence over which setter method is used, so that a
setter can take a parameter that's the type of the database column but convert it to the internally
stored type.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message