commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <>
Subject Re: [dbutils] Does DbUtils handle boolean variables in beans?
Date Thu, 04 Mar 2004 01:15:13 GMT
--- Lian Liu <> wrote:
> Hi,
> I have a question on DBUtils.  When I pass in a BeanListHandler to
> QueryRunner's runQuery method, I expect that the bean will be populated
> with the query results that I get back.  What if I have a boolean
> variable
> in the bean, and the matching field in database is a smallint type? It
> appears to me that the boolean value is always set to false even if the
> value in database is 1.  Thank you in advance.

DbUtils 1.0 uses ResultSet.getObject() to retrieve the value to set into
the bean property.  If the type returned from getObject() does not match
the bean property type, the bean's setter method is not called.  So,
what's probably happening is an integer is being returned so it doesn't
set your boolean property.

This is a common problem so we added the ColumnProcessor interface to
allow customizing this process.  The provided BasicColumnProcessor
implementation detects the type of bean property and calls the appropriate
ResultSet.get* method.  In your case it would see that it's a boolean
property and call ResultSet.getBoolean().  

Of course, if your JDBC driver doesn't convert from smallints to booleans
correctly you will still have a problem but that's outside of DbUtils'

Download a nightly build to try out the new interface and let us know if
it works.  Please prefix messages to the mailing list with the component
name [dbutils] so people can filter messages easily :-).


> thanks,
> Lian Liu
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Do you Yahoo!?
Yahoo! Search - Find what you’re looking for faster

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

View raw message