4. Application Migration and Compatibility Concerns

This chapter covers compatibility issues you might encounter as you migrate Spring 2.5.6 applications to Spring 3.0.

4.1 Changing Spring 2.5.6 Generics to Match 3.0 Generics

If you use generics in your 2.5.6 code, you might find a mismatch with the generics declarations used in Spring 3.0.

For example, the following code worked in Spring 2.5.6:

List<Map> list = jdbcTemplate.queryForList(queryString);

This code does not work in Spring 3.0 because the actual return type of that method is now declared as List<Map<String, Object>>. The Java compiler gives an "inconvertible types" error. You must change the code to use the matching generic return type:

List<Map<String, Object>> list = jdbcTemplate.queryForList(queryString);

The problem mentioned above only causes a problem when you try to compile the code. Binary compatibility should still be maintained and the first, compiled with Spring 2.5 jars, example should execute without problems with the Spring 3.0 jar files.