commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emerson Cargnin <emer...@tre-sc.gov.br>
Subject Re: DbUtils question
Date Wed, 03 Dec 2003 18:11:59 GMT


David Graham wrote:
> --- Emerson Cargnin <emerson@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 <emerson@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


Mime
View raw message