May 7th, 2009, 03:19 PM
Spring 3 queryForList Returntypechanged
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.
May 7th, 2009, 03:40 PM
"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?
May 7th, 2009, 03:48 PM
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
found : java.util.List<java.util.Map<java.lang.String,java .lang.Object>>
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.
May 8th, 2009, 10:23 AM
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.
Tags for this Thread