T - the mapped typepublic final class RowMapperImpl<T> extends Object implements org.springframework.jdbc.core.RowMapper<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 |
|---|
RowMapperImpl(org.simpleflatmapper.jdbc.JdbcMapper<T> mapper) |
public RowMapperImpl(org.simpleflatmapper.jdbc.JdbcMapper<T> mapper)
public T mapRow(ResultSet rs, int rowNum) throws SQLException
mapRow in interface org.springframework.jdbc.core.RowMapper<T>SQLExceptionCopyright © 2018. All rights reserved.