You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Emerson Cargnin <em...@tre-sc.gov.br> on 2003/12/03 16:38:58 UTC

DbUtils question

I'm giving my first steps into dbutils, and i'd like to make a question, 
since the docs are still  small:

What's the mapping from the db field names and the get/set properties of 
my bean (the one sent to the sqlrunner).

an example :

if I have a sql command
select * from mytable

my table has two fields :

id
id_othertable

What's are the allowed get/set mapping to get the bean with all the 
properties of the resultset.

it can translate from id_company to setCompany ?? or I have to use the 
'as', modifying all the sql's?

Anyone could show me some complete examples???

Thanks and congratulation for this excellent tool.


-- 
Emerson Cargnin
Analista de Sistemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by Emerson Cargnin <em...@tre-sc.gov.br>.

David Graham wrote:
> --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> 
>>It looks that my problem is with oracle number fields. WHat's the 
>>mapping for bean and database types?
> 
> 
> DbUtils 1.0 performs a very simple mapping: If the column type matches the
> bean type exactly, the setter will be called.  We have added an
> enhancement to be released with 1.1 that performs a more useful mapping. 
> We will also make changes to BasicRowProcessor to make customized mappings
> easier to implement.
> 
> Also see the javadoc:
> http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)
> 

Ok, I'm having a problem :

I have a bean that has getIdEmpresa/setIdEmpresa methods.
My sql is:

It happens that all fields are properly populated, except ones that had 
number (oracle) as the type of the field.

I tried to change my bean field to int or Integer, still not working. 
Should I use long for oracle number type ?

> 
>>As a suggestion, for the subject of naming mappings, dbutils could try 
>>to map getAttName bean method to att_name database field.
> 
> 
> DbUtils will not perform this kind of custom mapping.  You can either use
> an SQL "AS" or write a custom RowProcessor implementation.
> 
Now it doesn't work this way, you mean that it's not a good idea to be 
implemented in a future version? I think that this way (not excluding 
the way it works now) would be less intrusive in the sql's people have 
already, and since the filed_name being the pattern that is most used 
for filed names, it could avoid changing sql's to adapt to the DbUtils 
framework.

> David
> 
> 
>>David Graham wrote:
>>
>>>--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
>>>
>>>
>>>>I'm giving my first steps into dbutils, and i'd like to make a
>>>
>>question,
>>
>>>>since the docs are still  small:
>>>>
>>>>What's the mapping from the db field names and the get/set properties
>>>
>>of
>>
>>>>my bean (the one sent to the sqlrunner).
>>>>
>>>>an example :
>>>>
>>>>if I have a sql command
>>>>select * from mytable
>>>>
>>>>my table has two fields :
>>>>
>>>>id
>>>>id_othertable
>>>>
>>>>What's are the allowed get/set mapping to get the bean with all the 
>>>>properties of the resultset.
>>>>
>>>>it can translate from id_company to setCompany ?? or I have to use the
>>>
>>>>'as', modifying all the sql's?
>>>
>>>
>>>You should use an SQL "AS" to change the column names to match your
>>
>>bean
>>
>>>property names.  Your id column would call setId() on your bean.  I'm
>>
>>not
>>
>>>sure about id_othertable because it contains an underscore but it
>>
>>should
>>
>>>call setId_othertable.
>>>
>>>David
>>>
>>>
>>>
>>>>Anyone could show me some complete examples???
>>>>
>>>>Thanks and congratulation for this excellent tool.
>>>>
>>>>
>>>>-- 
>>>>Emerson Cargnin
>>>>Analista de Sistemas
>>>>Setor de Desenvolvimento de Sistemas - TRE-SC
>>>>tel : (048) - 251-3700 - Ramal 3181
>>>>
>>>>
>>>>---------------------------------------------------------------------
>>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>>
>>>
>>>
>>>
>>>__________________________________
>>>Do you Yahoo!?
>>>Free Pop-Up Blocker - Get it now
>>>http://companion.yahoo.com/
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>>-- 
>>Emerson Cargnin
>>Analista de Sistemas
>>Setor de Desenvolvimento de Sistemas - TRE-SC
>>tel : (048) - 251-3700 - Ramal 3181
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
Emerson Cargnin
Analista de Sistemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by David Graham <gr...@yahoo.com>.
--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> is there any way to use DBUtils to get a plain resultset, without having
> 
> to use it to populate the bean(s)?

No, because DbUtils cleans up Connection and PreparedStatement objects for
you so it can't give you the ResultSet.  Plus, it would defeat the main
purpose of DbUtils.  However, you can use DbUtils to convert ResultSets
into any arbitrary set of Objects, not just beans.

David

> 
> David Graham wrote:
> > Try BigInteger.  I think the problem you're experienceing is what
> caused
> > other people to suggest smarter bean handling for 1.1.  You might try
> a
> > 1.1 nightly build to see if that works.
> > 
> > David
> > 
> > --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> > 
> >>forgot to insert the sql :)
> >>
> >>David Graham wrote:
> >> > --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> >> >
> >> >>It looks that my problem is with oracle number fields. WHat's the
> >> >>mapping for bean and database types?
> >> >
> >> >
> >> > DbUtils 1.0 performs a very simple mapping: If the column type 
> >>matches the
> >> > bean type exactly, the setter will be called.  We have added an
> >> > enhancement to be released with 1.1 that performs a more useful
> >>mapping.
> >> > We will also make changes to BasicRowProcessor to make customized 
> >>mappings
> >> > easier to implement.
> >> >
> >> > Also see the javadoc:
> >> > 
> >>
> > 
> >
>
http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)
> > 
> >> >
> >>
> >>Ok, I'm having a problem :
> >>
> >>I have a bean that has getIdEmpresa/setIdEmpresa methods.
> >>My sql is:
> >>
> >>"SELECT id_empresa as idEmpresa , Nom_empresa as nome ,Num_tel_empresa
> 
> >>as telefone , fax, des_endereco as endereco , nom_bairro as bairro , 
> >>cep, email, razao, id_tipo as idTipo , sgl_uf as uF
> >>FROM empresa
> >>  WHERE id_empresa=?"
> >>
> >>It happens that all fields are properly populated, except ones that
> had
> >>number (oracle) as the type of the field.
> >>
> >>I tried to change my bean field to int or Integer, still not working.
> >>Should I use long for oracle number type ?
> >>
> >> >
> >> >>As a suggestion, for the subject of naming mappings, dbutils could
> >>try
> >> >>to map getAttName bean method to att_name database field.
> >> >
> >> >
> >> > DbUtils will not perform this kind of custom mapping.  You can
> either
> >>use
> >> > an SQL "AS" or write a custom RowProcessor implementation.
> >> >
> >>Now it doesn't work this way, you mean that it's not a good idea to be
> >>implemented in a future version? I think that this way (not excluding
> >>the way it works now) would be less intrusive in the sql's people have
> >>already, and since the filed_name being the pattern that is most used
> >>for filed names, it could avoid changing sql's to adapt to the DbUtils
> >>framework.
> >>
> >> > David
> >> >
> >> >
> >> >>David Graham wrote:
> >> >>
> >> >>>--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> >> >>>
> >> >>>
> >> >>>>I'm giving my first steps into dbutils, and i'd like to make a
> >> >>>
> >> >>question,
> >> >>
> >> >>>>since the docs are still  small:
> >> >>>>
> >> >>>>What's the mapping from the db field names and the get/set
> >>properties
> >> >>>
> >> >>of
> >> >>
> >> >>>>my bean (the one sent to the sqlrunner).
> >> >>>>
> >> >>>>an example :
> >> >>>>
> >> >>>>if I have a sql command
> >> >>>>select * from mytable
> >> >>>>
> >> >>>>my table has two fields :
> >> >>>>
> >> >>>>id
> >> >>>>id_othertable
> >> >>>>
> >> >>>>What's are the allowed get/set mapping to get the bean with all
> the
> >> >>>>properties of the resultset.
> >> >>>>
> >> >>>>it can translate from id_company to setCompany ?? or I have to
> use
> >>the
> >> >>>
> >> >>>>'as', modifying all the sql's?
> >> >>>
> >> >>>
> >> >>>You should use an SQL "AS" to change the column names to match
> your
> >> >>
> >> >>bean
> >> >>
> >> >>>property names.  Your id column would call setId() on your bean. 
> >>I'm
> >> >>
> >> >>not
> >> >>
> >> >>>sure about id_othertable because it contains an underscore but it
> >> >>
> >> >>should
> >> >>
> >> >>>call setId_othertable.
> >> >>>
> >> >>>David
> >> >>>
> >> >>>
> >> >>>
> >> >>>>Anyone could show me some complete examples???
> >> >>>>
> >> >>>>Thanks and congratulation for this excellent tool.
> >> >>>>
> >> >>>>
> >> >>>>--
> >> >>>>Emerson Cargnin
> >> >>>>Analista de Sistemas
> >> >>>>Setor de Desenvolvimento de Sistemas - TRE-SC
> >> >>>>tel : (048) - 251-3700 - Ramal 3181
> >> >>>>
> >> >>>>
> >>
> >>
>
>>>>>---------------------------------------------------------------------
> >>>>
> >> >>>>To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> >> >>>>For additional commands, e-mail:
> >>commons-user-help@jakarta.apache.org
> >> >>>>
> >> >>>
> >> >>>
> >> >>>
> >> >>>__________________________________
> >> >>>Do you Yahoo!?
> >> >>>Free Pop-Up Blocker - Get it now
> >> >>>http://companion.yahoo.com/
> >> >>>
> >>
>
>>>>>---------------------------------------------------------------------
> >>>>
> >> >>>To unsubscribe, e-mail:
> commons-user-unsubscribe@jakarta.apache.org
> >> >>>For additional commands, e-mail:
> >>commons-user-help@jakarta.apache.org
> >> >>>
> >> >>>
> >> >>
> >> >>
> >> >>--
> >> >>Emerson Cargnin
> >> >>Analista de Sistemas
> >> >>Setor de Desenvolvimento de Sistemas - TRE-SC
> >> >>tel : (048) - 251-3700 - Ramal 3181
> >> >>
> >> >>
> >>
> >>---------------------------------------------------------------------
> >> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >> >>For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
> >> >>
> >> >
> >> >
> >> >
> >> > __________________________________
> >> > Do you Yahoo!?
> >> > Free Pop-Up Blocker - Get it now
> >> > http://companion.yahoo.com/
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by Emerson Cargnin <em...@tre-sc.gov.br>.
is there any way to use DBUtils to get a plain resultset, without having 
to use it to populate the bean(s)?

David Graham wrote:
> Try BigInteger.  I think the problem you're experienceing is what caused
> other people to suggest smarter bean handling for 1.1.  You might try a
> 1.1 nightly build to see if that works.
> 
> David
> 
> --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> 
>>forgot to insert the sql :)
>>
>>David Graham wrote:
>> > --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
>> >
>> >>It looks that my problem is with oracle number fields. WHat's the
>> >>mapping for bean and database types?
>> >
>> >
>> > DbUtils 1.0 performs a very simple mapping: If the column type 
>>matches the
>> > bean type exactly, the setter will be called.  We have added an
>> > enhancement to be released with 1.1 that performs a more useful
>>mapping.
>> > We will also make changes to BasicRowProcessor to make customized 
>>mappings
>> > easier to implement.
>> >
>> > Also see the javadoc:
>> > 
>>
> 
> http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)
> 
>> >
>>
>>Ok, I'm having a problem :
>>
>>I have a bean that has getIdEmpresa/setIdEmpresa methods.
>>My sql is:
>>
>>"SELECT id_empresa as idEmpresa , Nom_empresa as nome ,Num_tel_empresa 
>>as telefone , fax, des_endereco as endereco , nom_bairro as bairro , 
>>cep, email, razao, id_tipo as idTipo , sgl_uf as uF
>>FROM empresa
>>  WHERE id_empresa=?"
>>
>>It happens that all fields are properly populated, except ones that had
>>number (oracle) as the type of the field.
>>
>>I tried to change my bean field to int or Integer, still not working.
>>Should I use long for oracle number type ?
>>
>> >
>> >>As a suggestion, for the subject of naming mappings, dbutils could
>>try
>> >>to map getAttName bean method to att_name database field.
>> >
>> >
>> > DbUtils will not perform this kind of custom mapping.  You can either
>>use
>> > an SQL "AS" or write a custom RowProcessor implementation.
>> >
>>Now it doesn't work this way, you mean that it's not a good idea to be
>>implemented in a future version? I think that this way (not excluding
>>the way it works now) would be less intrusive in the sql's people have
>>already, and since the filed_name being the pattern that is most used
>>for filed names, it could avoid changing sql's to adapt to the DbUtils
>>framework.
>>
>> > David
>> >
>> >
>> >>David Graham wrote:
>> >>
>> >>>--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
>> >>>
>> >>>
>> >>>>I'm giving my first steps into dbutils, and i'd like to make a
>> >>>
>> >>question,
>> >>
>> >>>>since the docs are still  small:
>> >>>>
>> >>>>What's the mapping from the db field names and the get/set
>>properties
>> >>>
>> >>of
>> >>
>> >>>>my bean (the one sent to the sqlrunner).
>> >>>>
>> >>>>an example :
>> >>>>
>> >>>>if I have a sql command
>> >>>>select * from mytable
>> >>>>
>> >>>>my table has two fields :
>> >>>>
>> >>>>id
>> >>>>id_othertable
>> >>>>
>> >>>>What's are the allowed get/set mapping to get the bean with all the
>> >>>>properties of the resultset.
>> >>>>
>> >>>>it can translate from id_company to setCompany ?? or I have to use
>>the
>> >>>
>> >>>>'as', modifying all the sql's?
>> >>>
>> >>>
>> >>>You should use an SQL "AS" to change the column names to match your
>> >>
>> >>bean
>> >>
>> >>>property names.  Your id column would call setId() on your bean. 
>>I'm
>> >>
>> >>not
>> >>
>> >>>sure about id_othertable because it contains an underscore but it
>> >>
>> >>should
>> >>
>> >>>call setId_othertable.
>> >>>
>> >>>David
>> >>>
>> >>>
>> >>>
>> >>>>Anyone could show me some complete examples???
>> >>>>
>> >>>>Thanks and congratulation for this excellent tool.
>> >>>>
>> >>>>
>> >>>>--
>> >>>>Emerson Cargnin
>> >>>>Analista de Sistemas
>> >>>>Setor de Desenvolvimento de Sistemas - TRE-SC
>> >>>>tel : (048) - 251-3700 - Ramal 3181
>> >>>>
>> >>>>
>>
>>
>>>>>---------------------------------------------------------------------
>>>>
>> >>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> >>>>For additional commands, e-mail:
>>commons-user-help@jakarta.apache.org
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>>__________________________________
>> >>>Do you Yahoo!?
>> >>>Free Pop-Up Blocker - Get it now
>> >>>http://companion.yahoo.com/
>> >>>
>>
>>>>>---------------------------------------------------------------------
>>>>
>> >>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> >>>For additional commands, e-mail:
>>commons-user-help@jakarta.apache.org
>> >>>
>> >>>
>> >>
>> >>
>> >>--
>> >>Emerson Cargnin
>> >>Analista de Sistemas
>> >>Setor de Desenvolvimento de Sistemas - TRE-SC
>> >>tel : (048) - 251-3700 - Ramal 3181
>> >>
>> >>
>> >>---------------------------------------------------------------------
>> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>> >>
>> >
>> >
>> >
>> > __________________________________
>> > Do you Yahoo!?
>> > Free Pop-Up Blocker - Get it now
>> > http://companion.yahoo.com/
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
>> >
>> >
>>
>>
>>-- 
>>Emerson Cargnin
>>Analista de Sistemas
>>Setor de Desenvolvimento de Sistemas - TRE-SC
>>tel : (048) - 251-3700 - Ramal 3181
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
Emerson Cargnin
Analista de Sistemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by David Graham <gr...@yahoo.com>.
Try BigInteger.  I think the problem you're experienceing is what caused
other people to suggest smarter bean handling for 1.1.  You might try a
1.1 nightly build to see if that works.

David

--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> forgot to insert the sql :)
> 
> David Graham wrote:
>  > --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
>  >
>  >>It looks that my problem is with oracle number fields. WHat's the
>  >>mapping for bean and database types?
>  >
>  >
>  > DbUtils 1.0 performs a very simple mapping: If the column type 
> matches the
>  > bean type exactly, the setter will be called.  We have added an
>  > enhancement to be released with 1.1 that performs a more useful
> mapping.
>  > We will also make changes to BasicRowProcessor to make customized 
> mappings
>  > easier to implement.
>  >
>  > Also see the javadoc:
>  > 
>
http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)
>  >
> 
> Ok, I'm having a problem :
> 
> I have a bean that has getIdEmpresa/setIdEmpresa methods.
> My sql is:
> 
> "SELECT id_empresa as idEmpresa , Nom_empresa as nome ,Num_tel_empresa 
> as telefone , fax, des_endereco as endereco , nom_bairro as bairro , 
> cep, email, razao, id_tipo as idTipo , sgl_uf as uF
> FROM empresa
>   WHERE id_empresa=?"
> 
> It happens that all fields are properly populated, except ones that had
> number (oracle) as the type of the field.
> 
> I tried to change my bean field to int or Integer, still not working.
> Should I use long for oracle number type ?
> 
>  >
>  >>As a suggestion, for the subject of naming mappings, dbutils could
> try
>  >>to map getAttName bean method to att_name database field.
>  >
>  >
>  > DbUtils will not perform this kind of custom mapping.  You can either
> use
>  > an SQL "AS" or write a custom RowProcessor implementation.
>  >
> Now it doesn't work this way, you mean that it's not a good idea to be
> implemented in a future version? I think that this way (not excluding
> the way it works now) would be less intrusive in the sql's people have
> already, and since the filed_name being the pattern that is most used
> for filed names, it could avoid changing sql's to adapt to the DbUtils
> framework.
> 
>  > David
>  >
>  >
>  >>David Graham wrote:
>  >>
>  >>>--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
>  >>>
>  >>>
>  >>>>I'm giving my first steps into dbutils, and i'd like to make a
>  >>>
>  >>question,
>  >>
>  >>>>since the docs are still  small:
>  >>>>
>  >>>>What's the mapping from the db field names and the get/set
> properties
>  >>>
>  >>of
>  >>
>  >>>>my bean (the one sent to the sqlrunner).
>  >>>>
>  >>>>an example :
>  >>>>
>  >>>>if I have a sql command
>  >>>>select * from mytable
>  >>>>
>  >>>>my table has two fields :
>  >>>>
>  >>>>id
>  >>>>id_othertable
>  >>>>
>  >>>>What's are the allowed get/set mapping to get the bean with all the
>  >>>>properties of the resultset.
>  >>>>
>  >>>>it can translate from id_company to setCompany ?? or I have to use
> the
>  >>>
>  >>>>'as', modifying all the sql's?
>  >>>
>  >>>
>  >>>You should use an SQL "AS" to change the column names to match your
>  >>
>  >>bean
>  >>
>  >>>property names.  Your id column would call setId() on your bean. 
> I'm
>  >>
>  >>not
>  >>
>  >>>sure about id_othertable because it contains an underscore but it
>  >>
>  >>should
>  >>
>  >>>call setId_othertable.
>  >>>
>  >>>David
>  >>>
>  >>>
>  >>>
>  >>>>Anyone could show me some complete examples???
>  >>>>
>  >>>>Thanks and congratulation for this excellent tool.
>  >>>>
>  >>>>
>  >>>>--
>  >>>>Emerson Cargnin
>  >>>>Analista de Sistemas
>  >>>>Setor de Desenvolvimento de Sistemas - TRE-SC
>  >>>>tel : (048) - 251-3700 - Ramal 3181
>  >>>>
>  >>>>
> 
>
>>>>---------------------------------------------------------------------
>  >>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>  >>>>For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
>  >>>>
>  >>>
>  >>>
>  >>>
>  >>>__________________________________
>  >>>Do you Yahoo!?
>  >>>Free Pop-Up Blocker - Get it now
>  >>>http://companion.yahoo.com/
>  >>>
> 
> >>>---------------------------------------------------------------------
>  >>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>  >>>For additional commands, e-mail:
> commons-user-help@jakarta.apache.org
>  >>>
>  >>>
>  >>
>  >>
>  >>--
>  >>Emerson Cargnin
>  >>Analista de Sistemas
>  >>Setor de Desenvolvimento de Sistemas - TRE-SC
>  >>tel : (048) - 251-3700 - Ramal 3181
>  >>
>  >>
>  >>---------------------------------------------------------------------
>  >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>  >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>  >>
>  >
>  >
>  >
>  > __________________________________
>  > Do you Yahoo!?
>  > Free Pop-Up Blocker - Get it now
>  > http://companion.yahoo.com/
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>  > For additional commands, e-mail: commons-user-help@jakarta.apache.org
>  >
>  >
> 
> 
> -- 
> Emerson Cargnin
> Analista de Sistemas
> Setor de Desenvolvimento de Sistemas - TRE-SC
> tel : (048) - 251-3700 - Ramal 3181
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by Emerson Cargnin <em...@tre-sc.gov.br>.
forgot to insert the sql :)

David Graham wrote:
 > --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
 >
 >>It looks that my problem is with oracle number fields. WHat's the
 >>mapping for bean and database types?
 >
 >
 > DbUtils 1.0 performs a very simple mapping: If the column type 
matches the
 > bean type exactly, the setter will be called.  We have added an
 > enhancement to be released with 1.1 that performs a more useful mapping.
 > We will also make changes to BasicRowProcessor to make customized 
mappings
 > easier to implement.
 >
 > Also see the javadoc:
 > 
http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)
 >

Ok, I'm having a problem :

I have a bean that has getIdEmpresa/setIdEmpresa methods.
My sql is:

"SELECT id_empresa as idEmpresa , Nom_empresa as nome ,Num_tel_empresa 
as telefone , fax, des_endereco as endereco , nom_bairro as bairro , 
cep, email, razao, id_tipo as idTipo , sgl_uf as uF
FROM empresa
  WHERE id_empresa=?"

It happens that all fields are properly populated, except ones that had
number (oracle) as the type of the field.

I tried to change my bean field to int or Integer, still not working.
Should I use long for oracle number type ?

 >
 >>As a suggestion, for the subject of naming mappings, dbutils could try
 >>to map getAttName bean method to att_name database field.
 >
 >
 > DbUtils will not perform this kind of custom mapping.  You can either use
 > an SQL "AS" or write a custom RowProcessor implementation.
 >
Now it doesn't work this way, you mean that it's not a good idea to be
implemented in a future version? I think that this way (not excluding
the way it works now) would be less intrusive in the sql's people have
already, and since the filed_name being the pattern that is most used
for filed names, it could avoid changing sql's to adapt to the DbUtils
framework.

 > David
 >
 >
 >>David Graham wrote:
 >>
 >>>--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
 >>>
 >>>
 >>>>I'm giving my first steps into dbutils, and i'd like to make a
 >>>
 >>question,
 >>
 >>>>since the docs are still  small:
 >>>>
 >>>>What's the mapping from the db field names and the get/set properties
 >>>
 >>of
 >>
 >>>>my bean (the one sent to the sqlrunner).
 >>>>
 >>>>an example :
 >>>>
 >>>>if I have a sql command
 >>>>select * from mytable
 >>>>
 >>>>my table has two fields :
 >>>>
 >>>>id
 >>>>id_othertable
 >>>>
 >>>>What's are the allowed get/set mapping to get the bean with all the
 >>>>properties of the resultset.
 >>>>
 >>>>it can translate from id_company to setCompany ?? or I have to use the
 >>>
 >>>>'as', modifying all the sql's?
 >>>
 >>>
 >>>You should use an SQL "AS" to change the column names to match your
 >>
 >>bean
 >>
 >>>property names.  Your id column would call setId() on your bean.  I'm
 >>
 >>not
 >>
 >>>sure about id_othertable because it contains an underscore but it
 >>
 >>should
 >>
 >>>call setId_othertable.
 >>>
 >>>David
 >>>
 >>>
 >>>
 >>>>Anyone could show me some complete examples???
 >>>>
 >>>>Thanks and congratulation for this excellent tool.
 >>>>
 >>>>
 >>>>--
 >>>>Emerson Cargnin
 >>>>Analista de Sistemas
 >>>>Setor de Desenvolvimento de Sistemas - TRE-SC
 >>>>tel : (048) - 251-3700 - Ramal 3181
 >>>>
 >>>>
 >>>>---------------------------------------------------------------------
 >>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
 >>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
 >>>>
 >>>
 >>>
 >>>
 >>>__________________________________
 >>>Do you Yahoo!?
 >>>Free Pop-Up Blocker - Get it now
 >>>http://companion.yahoo.com/
 >>>
 >>>---------------------------------------------------------------------
 >>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
 >>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
 >>>
 >>>
 >>
 >>
 >>--
 >>Emerson Cargnin
 >>Analista de Sistemas
 >>Setor de Desenvolvimento de Sistemas - TRE-SC
 >>tel : (048) - 251-3700 - Ramal 3181
 >>
 >>
 >>---------------------------------------------------------------------
 >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
 >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
 >>
 >
 >
 >
 > __________________________________
 > Do you Yahoo!?
 > Free Pop-Up Blocker - Get it now
 > http://companion.yahoo.com/
 >
 > ---------------------------------------------------------------------
 > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
 > For additional commands, e-mail: commons-user-help@jakarta.apache.org
 >
 >


-- 
Emerson Cargnin
Analista de Sistemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by David Graham <gr...@yahoo.com>.
--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> It looks that my problem is with oracle number fields. WHat's the 
> mapping for bean and database types?

DbUtils 1.0 performs a very simple mapping: If the column type matches the
bean type exactly, the setter will be called.  We have added an
enhancement to be released with 1.1 that performs a more useful mapping. 
We will also make changes to BasicRowProcessor to make customized mappings
easier to implement.

Also see the javadoc:
http://jakarta.apache.org/commons/dbutils/apidocs/org/apache/commons/dbutils/BasicRowProcessor.html#toBean(java.sql.ResultSet,%20java.lang.Class)

> 
> As a suggestion, for the subject of naming mappings, dbutils could try 
> to map getAttName bean method to att_name database field.

DbUtils will not perform this kind of custom mapping.  You can either use
an SQL "AS" or write a custom RowProcessor implementation.

David

> 
> David Graham wrote:
> > --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> > 
> >>I'm giving my first steps into dbutils, and i'd like to make a
> question,
> >>
> >>since the docs are still  small:
> >>
> >>What's the mapping from the db field names and the get/set properties
> of
> >>
> >>my bean (the one sent to the sqlrunner).
> >>
> >>an example :
> >>
> >>if I have a sql command
> >>select * from mytable
> >>
> >>my table has two fields :
> >>
> >>id
> >>id_othertable
> >>
> >>What's are the allowed get/set mapping to get the bean with all the 
> >>properties of the resultset.
> >>
> >>it can translate from id_company to setCompany ?? or I have to use the
> 
> >>'as', modifying all the sql's?
> > 
> > 
> > You should use an SQL "AS" to change the column names to match your
> bean
> > property names.  Your id column would call setId() on your bean.  I'm
> not
> > sure about id_othertable because it contains an underscore but it
> should
> > call setId_othertable.
> > 
> > David
> > 
> > 
> >>Anyone could show me some complete examples???
> >>
> >>Thanks and congratulation for this excellent tool.
> >>
> >>
> >>-- 
> >>Emerson Cargnin
> >>Analista de Sistemas
> >>Setor de Desenvolvimento de Sistemas - TRE-SC
> >>tel : (048) - 251-3700 - Ramal 3181
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >>For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> > 
> > 
> > 
> > __________________________________
> > Do you Yahoo!?
> > Free Pop-Up Blocker - Get it now
> > http://companion.yahoo.com/
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > 
> > 
> 
> 
> -- 
> Emerson Cargnin
> Analista de Sistemas
> Setor de Desenvolvimento de Sistemas - TRE-SC
> tel : (048) - 251-3700 - Ramal 3181
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by Emerson Cargnin <em...@tre-sc.gov.br>.
It looks that my problem is with oracle number fields. WHat's the 
mapping for bean and database types?

As a suggestion, for the subject of naming mappings, dbutils could try 
to map getAttName bean method to att_name database field.

David Graham wrote:
> --- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> 
>>I'm giving my first steps into dbutils, and i'd like to make a question,
>>
>>since the docs are still  small:
>>
>>What's the mapping from the db field names and the get/set properties of
>>
>>my bean (the one sent to the sqlrunner).
>>
>>an example :
>>
>>if I have a sql command
>>select * from mytable
>>
>>my table has two fields :
>>
>>id
>>id_othertable
>>
>>What's are the allowed get/set mapping to get the bean with all the 
>>properties of the resultset.
>>
>>it can translate from id_company to setCompany ?? or I have to use the 
>>'as', modifying all the sql's?
> 
> 
> You should use an SQL "AS" to change the column names to match your bean
> property names.  Your id column would call setId() on your bean.  I'm not
> sure about id_othertable because it contains an underscore but it should
> call setId_othertable.
> 
> David
> 
> 
>>Anyone could show me some complete examples???
>>
>>Thanks and congratulation for this excellent tool.
>>
>>
>>-- 
>>Emerson Cargnin
>>Analista de Sistemas
>>Setor de Desenvolvimento de Sistemas - TRE-SC
>>tel : (048) - 251-3700 - Ramal 3181
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
Emerson Cargnin
Analista de Sistemas
Setor de Desenvolvimento de Sistemas - TRE-SC
tel : (048) - 251-3700 - Ramal 3181


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: DbUtils question

Posted by David Graham <gr...@yahoo.com>.
--- Emerson Cargnin <em...@tre-sc.gov.br> wrote:
> I'm giving my first steps into dbutils, and i'd like to make a question,
> 
> since the docs are still  small:
> 
> What's the mapping from the db field names and the get/set properties of
> 
> my bean (the one sent to the sqlrunner).
> 
> an example :
> 
> if I have a sql command
> select * from mytable
> 
> my table has two fields :
> 
> id
> id_othertable
> 
> What's are the allowed get/set mapping to get the bean with all the 
> properties of the resultset.
> 
> it can translate from id_company to setCompany ?? or I have to use the 
> 'as', modifying all the sql's?

You should use an SQL "AS" to change the column names to match your bean
property names.  Your id column would call setId() on your bean.  I'm not
sure about id_othertable because it contains an underscore but it should
call setId_othertable.

David

> 
> Anyone could show me some complete examples???
> 
> Thanks and congratulation for this excellent tool.
> 
> 
> -- 
> Emerson Cargnin
> Analista de Sistemas
> Setor de Desenvolvimento de Sistemas - TRE-SC
> tel : (048) - 251-3700 - Ramal 3181
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org