Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 87982 invoked from network); 4 Mar 2004 01:15:32 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Mar 2004 01:15:32 -0000 Received: (qmail 91858 invoked by uid 500); 4 Mar 2004 01:15:09 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 91760 invoked by uid 500); 4 Mar 2004 01:15:08 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 91728 invoked from network); 4 Mar 2004 01:15:07 -0000 Received: from unknown (HELO web60802.mail.yahoo.com) (216.155.196.65) by daedalus.apache.org with SMTP; 4 Mar 2004 01:15:07 -0000 Message-ID: <20040304011513.99405.qmail@web60802.mail.yahoo.com> Received: from [66.80.49.7] by web60802.mail.yahoo.com via HTTP; Wed, 03 Mar 2004 17:15:13 PST Date: Wed, 3 Mar 2004 17:15:13 -0800 (PST) From: David Graham Subject: Re: [dbutils] Does DbUtils handle boolean variables in beans? To: Jakarta Commons Developers List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --- 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' control. 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 :-). David > > thanks, > Lian Liu > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > __________________________________ Do you Yahoo!? Yahoo! Search - Find what you�re looking for faster http://search.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org