Results 1 to 4 of 4

Thread: Spring 3 queryForList Returntypechanged

  1. #1
    Join Date
    Jan 2008
    Posts
    5

    Default Spring 3 queryForList Returntypechanged

    Hi,
    I was trying to Include the spring3 m3 jars into my project and found that return type of queryForList has been changed from List<Map> to List<Map<String, Object>. This seems to throw compilation problems. I use jdk 1.5_011.

    Can this be taken care before the actual release of the product.

    -Sundar

  2. #2
    Join Date
    Aug 2004
    Posts
    1,110

    Default

    "seems to throw compilation problems" is a bit vague - could you be more specific, maybe post your code and the actual error you are seeing?
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  3. #3
    Join Date
    Jan 2008
    Posts
    5

    Default

    Code is
    List<Map> list = jdbcTemplate.queryForList(someQuery);

    Problem is (on Myeclipse)

    Cannot cast from List<Map<String,Object>> to List<Map>

    Problem from javacing using Ant is

    inconvertible types
    found : java.util.List<java.util.Map<java.lang.String,java .lang.Object>>
    required: java.util.List<java.util.Map>
    ================================================== ========

    It seems weird to me too as Java should technically be looking only @ list and not anything else.

    Both myeclipse and my ant script seemed to throw compilation problem.

  4. #4
    Join Date
    Aug 2004
    Posts
    1,110

    Default

    List<Map> is not the correct return type for queryForList in either Spring 2.5 or Spring 3.0.

    The correct type is

    for Spring 2.5: List
    for Spring 3.0: List<Map<String, Object>>

    Both of these return types work with Spring 2.5 and 3.0.

    List<Map> works with 2.5 since Java can cast from List to List<Map>. When we add generics in 3.0, the return type changes to List<Map<String, Object>> and this can't be cast to List<Map>, so you get a compilation error.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •