DbUtils will set numeric fields to 0 (just like JDBC) if their value is null. DbUtils will only call a setter method if the value's Class is compatible with the Class of the setter parameter. For example, if you have:
SomeBean.setSomeInteger(int i) but the value returned from rs.getObject() for the someInteger column is a Short, the setter won't get called. The nightly builds contain a new class called BasicColumnProcessor that should give you the functionality you need. This class performs a slightly more sophisticated type mapping between database columns and bean properties. David --- "Rafael U. C. Afonso" <[EMAIL PROTECTED]> wrote: > Hello: > > Yesterday I try use Commons DbUtils > library. But I have some problems. > I have a class called ocorrencia, with > primitives attributes (like codigo, > codTipoAtor, etc.) and non-primitives > attributes (dataOcorrencia and > observacao) - See Ocorrencia.java > attached. > I have a table called ocorrencia whose > columns hava same name that Ocorrencia > class attributes - table at end of > this mail. In TestChar class (see > TestChar.java attached), I try read > database and print a Ocorrencia list. > To do this I try in 2 ways: > > 1. Using > BasicRowProcessor.toBeanList() in > findAllByBasicRowProcessor() method. > 2. Using QueryRunner.query() in > findAllByRunQuery() method. > > Below results I got: > > Calling findAllByBasicRowProcessor() ... > Showing Ocorrencia.getCodigo() ... > 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - > Showing Ocorrencia.getObservacao() ... > alfa > bweta - qwdeqweqweqw - birita - > vitasmina - uga buga - 797987 > 464343 - qweqweqwe - observa��es - > 3r2aerwer - dfhettrttrtttr - > Showing Ocorrencia.getDataOcorrencia() ... > 2004-01-27 09:36:00.0 - 2004-01-27 > 10:20:00.0 - 2004-01-27 10:40:00.0 - > 2004-01-27 10:54:00.0 - 2004-01-27 > 12:42:00.0 - 2004-02-01 11:59:00.0 - > 2004-01-29 14:21:00.0 - 2004-01-29 > 14:24:00.0 - 2004-02-03 10:30:00.0 - > 2004-02-03 10:30:00.0 - > Showing TipoOcorrencia list (it does > not work) ... > [Ocorrencia[codigo=0, codAtor=0, > codTipoAtor= > > Calling findAllByRunQuery() ... > [Ocorrencia[codigo=0, codAtor=0, > codTipoAtor= > > > Well: findAllByBasicRowProcessor() and > findAllByRunQuery() do not work > corretly. Perceive that non-primitives > attributes are get normally, but > primitives attributes are with 0 > values. I think that DBUtil does not > work correctly with primitives attributes. > How to go round this problem? Would > you help me? > > Thanks, > > Rafael Ubiratam Clemente Afonso > [EMAIL PROTECTED] > --------------------------------- > Where is Debug? > Debug is on the Table! > > > --- > Acabe com aquelas janelinhas que pulam na sua tela. > AntiPop-up UOL - � gr�tis! > http://antipopup.uol.com.br > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! http://webhosting.yahoo.com/ps/sb/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
