commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: [beanutils] RowSetDynaClass
Date Thu, 11 Sep 2008 16:55:07 GMT
Thanks Niall,

I took your suggestion and just had to modify it a bit.  At first when I tried
your suggestion, my process crashed when it came across a java.sql.Timestamp
property.  What I did in the end was look at the source of JDBCDynaClass and I
copied some of the logic from it's getObject() method into my class that extends
RowSetDynaClass.  The code I copied basically handles Timestamp, Date and Time
properties just like JDBCDynaClass, except I'm handling them like "if else
if..." instead of just a normal if statement for each.  That allowed me to add
your suggested code as the last option in my if else if tree.

Thanks again.

             "Niall Pemberton"                                                  
   >                                                        To 
                                         "Commons Users List"                   
             09/10/2008 05:29 PM         <>              
              Please respond to                                         Subject 
               "Commons Users            Re: [beanutils] RowSetDynaClass        

On Wed, Sep 10, 2008 at 8:35 PM,  <> wrote:
> I'm having a ConversionException issue when creating a RowSetDynaClass from a
> ResultSet.  Apparently I'm not the only person's who's experienced this.  The
> exception is saying "Cannot assign value of type 'java.lang.Integer' to
> 'vsize' of type 'java.lang.Short'.  Does somebody have a solution to this
> problem?  I'm using Beanutils 1.8.

You could override the getObject(ResultSet, String) method and use
ConvertUtils to convert the value, something like:

protected Object getObject(ResultSet resultSet, String name) throws
SQLException {
    Object value = super.getObject(resultSet, name);
    DynaProperty property = getDynaProperty(name);
    if (property != null) {
        value = ConvertUtils.convert(value, property.getType());
    return value;

I did something like this for BEANUTILS-142[1] - but then backed it
out - because it didn't solve that particular issue - and used another
solution. But perhaps I should have left that in as well.



To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message