Useful for the typical case of one object per row in the database table. The number of entries in the results list will match the number of rows.
Note that a RowMapper object is typically stateless and thus reusable; just the RowMapperResultSetExtractor adapter is stateful.
A usage example with JdbcTemplate:
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); // reusable object RowMapper rowMapper = new UserRowMapper(); // reusable objectList allUsers = (List) jdbcTemplate.query( "select * from user", new RowMapperResultSetExtractor(rowMapper, 10));
User user = (User) jdbcTemplate.queryForObject( "select * from user where id=?", new Object[] {id}, new RowMapperResultSetExtractor(rowMapper, 1));
RowMapper, liquibase.executor.Executor
| Modifier and Type | Field and Description |
|---|---|
| protected final RowMapper | |
| protected final int |
| Access | Constructor and Description |
|---|---|
| public | RowMapperResultSetExtractor(RowMapper
the RowMapper which creates an object for each row rowMapper)Create a new RowMapperResultSetExtractor. |
| public | RowMapperResultSetExtractor(RowMapper
the RowMapper which creates an object for each row rowMapper, int the number of expected rows
(just used for optimized collection handling) rowsExpected)Create a new RowMapperResultSetExtractor. |
| Modifier and Type | Method and Description |
|---|---|
| public Object | extractData(ResultSet
ResultSet to extract data from. Implementations should
not close this: it will be closed by the calling JdbcTemplate. rs)Implements liquibase. Implementations must implement this method to process the entire ResultSet. |
| rowMapper | back to summary |
|---|---|
| protected final RowMapper rowMapper | |
| rowsExpected | back to summary |
|---|---|
| protected final int rowsExpected | |
| RowMapperResultSetExtractor | back to summary |
|---|---|
| public RowMapperResultSetExtractor(RowMapper rowMapper) Create a new RowMapperResultSetExtractor.
| |
| RowMapperResultSetExtractor | back to summary |
|---|---|
| public RowMapperResultSetExtractor(RowMapper rowMapper, int rowsExpected) Create a new RowMapperResultSetExtractor.
| |
| extractData | back to summary |
|---|---|
| public Object extractData(ResultSet rs) throws SQLException Implements liquibase. Doc from liquibase. Implementations must implement this method to process the entire ResultSet.
| |