I just started to learn Spring (3.2.8) and come across this question:
NamedParameterJdbcTemplate jdbc = (NamedParameterJdbcTemplate)ctx.getBean("namedjdbc");
Map<String, Object> params = new HashMap<String, Object>();
params.put("rownum", 10);
params.put("variablename", "FlyMark");
List<Variable> variables = jdbc.query(
"select materialname, variablename, variablevalue " +
"from tbl_variables " +
"where variablename = :variablename and rownum < :rownum",
params,
//BeanPropertyRowMapper.newInstance(Variable.class)
ParameterizedBeanPropertyRowMapper.newInstance(Variable.class)
);
It seems if I replace ParameterizedBeanPropertyRowMapper
with BeanPropertyRowMapper
, it works too and nothing different.
So my question is: what is ParameterizedBeanPropertyRowMapper
designed for?
As of Spring 3.0 the ParameterizedBeanPropertyRowMapper
and BeanPropertyRowMapper
are the same.
The ParameterizedBeanPropertyRowMapper
(actually everything in the org.springframework.jdbc.core.simple
package) was added in the time that Spring was compatible with java version < 1.5 which didn't had generics. To work around this restriction basically 2 implementations of classes started to emerge (one with and one without generics).
As of Spring 3.0 the minimum supported java version has been brought back to 1.5 and as such the seperate packages where merged into the core of the framework and made those parameterized versions obsolote. Most of the code (for instance SimpleJdbcTemplate
) is deprecated or at least should be considered deprecated. They are still there for backwards compatibility but will probably be removed in the next major release of Spring.
Links
ParameterizedRowMapper
SimpleJdbcTemplate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With