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.
Patrick



                                                                                
             "Niall Pemberton"                                                  
             <[EMAIL PROTECTED]                                                
             ail.com>                                                        To 
                                         "Commons Users List"                   
             09/10/2008 05:29 PM         <[email protected]>              
                                                                             cc 
                                                                                
              Please respond to                                         Subject 
               "Commons Users            Re: [beanutils] RowSetDynaClass        
                    List"                                                       
             <[EMAIL PROTECTED]                                                
                   e.org>                                                       
                                                                                
                                                                                
                                                                                




On Wed, Sep 10, 2008 at 8:35 PM,  <[EMAIL PROTECTED]> 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
property
> '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.

Niall


[1] http://issues.apache.org/jira/browse/BEANUTILS-142

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to