You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Thomas Mueller <hy...@gmx.net> on 2006/07/11 17:12:07 UTC

[DbUtils] Generic BasicRowProcessor toBeanList

Hi,

Currently, you need to do this:

List<Test> list = (List<Test>) BasicRowProcessor.instance().toBeanList(rs, Test.class);

what about using generics?

List<Test> list = BasicRowProcessor.instance().toBeanList(rs, Test.class);

public static <T> List<T> toBeanList(
        ResultSet rs, 
        Class<T> clazz) throws SQLException {
    return (List<T>) toBeanList(rs, clazz);    
}

Of course this would be required for other cases as well. I'm not sure if you should create a new class or overwrite the existing class for the generic version. Maybe the Class<T> could be removed in some way (I'm not a generics expert). 

Thomas

-- 


Echte DSL-Flatrate dauerhaft für 0,- Euro*!
"Feel free" mit GMX DSL! http://www.gmx.net/de/go/dsl

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


Re: [DbUtils] Generic BasicRowProcessor toBeanList

Posted by Kyle Miller <ky...@sbcglobal.net>.
You would lose backwards compatibility with 1.3 and
1.4.

--- Thomas Mueller <hy...@gmx.net> wrote:

> Hi,
> 
> Currently, you need to do this:
> 
> List<Test> list = (List<Test>)
> BasicRowProcessor.instance().toBeanList(rs,
> Test.class);
> 
> what about using generics?
> 
> List<Test> list =
> BasicRowProcessor.instance().toBeanList(rs,
> Test.class);
> 
> public static <T> List<T> toBeanList(
>         ResultSet rs, 
>         Class<T> clazz) throws SQLException {
>     return (List<T>) toBeanList(rs, clazz);    
> }
> 
> Of course this would be required for other cases as
> well. I'm not sure if you should create a new class
> or overwrite the existing class for the generic
> version. Maybe the Class<T> could be removed in some
> way (I'm not a generics expert). 
> 
> Thomas
> 
> -- 
> 
> 
> Echte DSL-Flatrate dauerhaft für 0,- Euro*!
> "Feel free" mit GMX DSL!
> http://www.gmx.net/de/go/dsl
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> commons-dev-help@jakarta.apache.org
> 
> 


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