Update from ParameterizedRowMapper to SingleColumnRowMapper for multiple columns

I am @Repository Spring 3 application to Spring 4. My @Repository has a ParameterizedRowMapper to map SQL results to objects. But since Spring 4, this interface was deprecated "in favor of the regular SingleColumnRowMapper ." But I use mappers to match multiple columns. How am I going to map multiple columns using SingleColumnRowMapper ? Or should I do something completely different?

For example, here is the code that I have now:

  private static final ParameterizedRowMapper<Thing> THING_ENTRY_MAPPER = new ParameterizedRowMapper<Thing>() { @Override public Thing mapRow(ResultSet rs, int rowNum) throws SQLException { return new Thing(rs.getLong(1), rs.getLong(2), rs.getInt(3)); } }; @Override public List<Thing> getThings( ID id, long start, long end) { final Map<String, Object> params = new HashMap<String, Object>(4); putIDParams(params, id); putTimeRangeParams(params, start, end); return getNamedParameterJdbcTemplate().query(QUERY_THING, params, THING_ENTRY_MAPPER); } 

How do I now implement this functionality?

+6
source share
1 answer

Javadok seems wrong. Spring Framework designers probably intend to use the RowMapper<Thing> interface to replace ParameterizedRowMapper<Thing> . That is, use the base interface.

+10
source

Source: https://habr.com/ru/post/976057/


All Articles