commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niall Pemberton" <niall.pember...@gmail.com>
Subject Re: [beanutils] RowSetDynaClass
Date Wed, 10 Sep 2008 21:28:45 GMT
On Wed, Sep 10, 2008 at 8:35 PM,  <Patrick.Grimard@xtl.com> 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: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message