Evil Washing Machine
Evil Washing Machine

Reputation: 1341

What List implementation does Spring's core.JdbcTemplate.query return?

More specifically for public <T> List<T> query(String sql, RowMapper<T> rowMapper) throws DataAccessException

I tried following through the source listing but it just gives me a bunch of data extractors and jdbc calls, with nowhere where it explicitly creates a List-subtype implementation. I'm curious because I want to find out how Spring manages to instantiate a List, or if it 'cheats' by returning a sub-implementation like in Arrays.asList.

Upvotes: 1

Views: 766

Answers (1)

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279930

JdbcTemplate#query(String, RowMapper) invokes the overloaded JdbcTemplate#query(String, ResultSetExtractor) by providing a RowMapperResultSetExtractor as an argument.

Its implementation of extractData creates a java.util.ArrayList.

Upvotes: 2

Related Questions