T
- the mapped typepublic final class ResultSetExtractorImpl<T> extends Object implements org.springframework.jdbc.core.ResultSetExtractor<List<T>>
It implements RowMapper
, PreparedStatementCallback
and ResultSetExtractor
.
Because some JdbcTemplate template signature match against a few of those type you might need to downcast, declare the variable with a specific type or use the type specific method in JdbcTemplateMapperFactory
.
class MyDao {
private final JdbcTemplateMapper<DbObject> jdbcMapper =
JdbcTemplateMapperFactory.newInstance().newMapper(DbObject.class);
private final RowMapper<DbObject> rowMapper = jdbcMapper;
public void doSomething() {
List<DbObject> results = template.query(DbHelper.TEST_DB_OBJECT_QUERY, rowMapper);
}
public void doSomethingElse() {
template
.query(TEST_DB_OBJECT_QUERY,
jdbcMapper.newResultSetExtractor((o) -> System.out.println(o.toString())));
}
}
JdbcMapperFactory
,
JdbcMapper
,
JdbcTemplateMapperFactory.newPreparedStatementCallback(Class)
,
JdbcTemplateMapperFactory.newResultSetExtractor(Class)
,
JdbcTemplateMapperFactory.newRowMapper(Class)
Constructor and Description |
---|
ResultSetExtractorImpl(org.simpleflatmapper.jdbc.JdbcMapper<T> mapper) |
Modifier and Type | Method and Description |
---|---|
List<T> |
extractData(ResultSet rs) |
<H extends org.simpleflatmapper.util.CheckedConsumer<T>> |
newResultSetExtractor(H handler) |
public ResultSetExtractorImpl(org.simpleflatmapper.jdbc.JdbcMapper<T> mapper)
public List<T> extractData(ResultSet rs) throws SQLException, org.springframework.dao.DataAccessException
extractData
in interface org.springframework.jdbc.core.ResultSetExtractor<List<T>>
SQLException
org.springframework.dao.DataAccessException
public <H extends org.simpleflatmapper.util.CheckedConsumer<T>> org.springframework.jdbc.core.ResultSetExtractor<H> newResultSetExtractor(H handler)
Copyright © 2018. All rights reserved.