-
May 7th, 2009, 03:19 PM
#1
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
-
May 7th, 2009, 03:40 PM
#2
"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
#3
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.
-
May 8th, 2009, 10:23 AM
#4
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules