Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 30541 invoked from network); 9 Nov 2006 17:04:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Nov 2006 17:04:22 -0000 Received: (qmail 36809 invoked by uid 500); 9 Nov 2006 17:04:29 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 36443 invoked by uid 500); 9 Nov 2006 17:04:28 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 36432 invoked by uid 99); 9 Nov 2006 17:04:28 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Nov 2006 09:04:28 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of flamefew@gmail.com designates 66.249.82.226 as permitted sender) Received: from [66.249.82.226] (HELO wx-out-0506.google.com) (66.249.82.226) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Nov 2006 09:04:14 -0800 Received: by wx-out-0506.google.com with SMTP id h29so239938wxd for ; Thu, 09 Nov 2006 09:03:53 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=R3UIp+TOwAvOH3ssSfHimXD4rK+RUwDeDHx33QV2NWHTnWxECNK9gGYb9xwGYSbLddTIlqiHGQ1vvZpyM4L+YJK36SL/tR11daLzL4/+Uen7Sid1U4xeZg8N/832Ry6auYr+xSJg9qWFvy7F4ka/OYy1U+eOexxesgOApMgmxUc= Received: by 10.90.54.4 with SMTP id c4mr790294aga.1163091833838; Thu, 09 Nov 2006 09:03:53 -0800 (PST) Received: by 10.90.101.10 with HTTP; Thu, 9 Nov 2006 09:03:53 -0800 (PST) Message-ID: <31cc37360611090903y7be210efh6d31eb788c526c78@mail.gmail.com> Date: Thu, 9 Nov 2006 09:03:53 -0800 From: "Henri Yandell" To: "Jakarta Commons Users List" Subject: Re: BeanUtils In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Virus-Checked: Checked by ClamAV on apache.org On 11/9/06, Qin Ding wrote: > in database, 'rqst_sts_cde' is defined as smallint. I don't know what > these 'Short' or 'Integer' come from. I guess from build-in converter. > What is 'smallint' supposed to convert to? And how to override the > build-in converter. Please help. Digging into the source, it looks like the Short is coming from the DB2 JDBC driver when BeanUtils asks it what type the DB2 smallint column should be represented as as a Java object. Line 169 ot JDBCDynaClass (in trunk): className = metadata.getColumnClassName(i); When BeanUtils then gets the data, it assumes that the object it gets via ResultSet.getObject (line 232 of RowSetDynaClass) is of the type that the database is advising it to use. I'm not sure if the JDBC spec intends for this to be done, but I suspect so. So I think this is a bug in the DB2 JDBC driver - it's not returning the type of Object it advises a client to create. Alfredo has the correct and easiest technical work-around - find a type that works with the JDBC driver at the database level - 'int' seems like a good choice. That might be hard to do if you're not in control of the schema though. Another work-around would be to extend RowSetDynaClass and override the copy(ResultSet) method to have a hack to get around this (by forcing the Integer into a Short when the underlying type is a Short), or more painfully, overriding createDynaBean() to return a dynabean that doesn't use Shorts but uses Integers instead. That involves overriding other methods though. Hen --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org