Package liquibase.executor.jvm
Class RowMapperResultSetExtractor
java.lang.Object
liquibase.executor.jvm.RowMapperResultSetExtractor
- Direct Known Subclasses:
RowMapperNotNullConstraintsResultSetExtractor
Adapter implementation of the ResultSetExtractor interface that delegates
to a RowMapper which is supposed to create an object for each row.
Each object is added to the results List of this ResultSetExtractor.
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 object List 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));
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRowMapperResultSetExtractor
(RowMapper rowMapper) Create a new RowMapperResultSetExtractor.RowMapperResultSetExtractor
(RowMapper rowMapper, int rowsExpected) Create a new RowMapperResultSetExtractor. -
Method Summary
-
Field Details
-
rowMapper
-
rowsExpected
protected final int rowsExpected
-
-
Constructor Details
-
RowMapperResultSetExtractor
Create a new RowMapperResultSetExtractor.- Parameters:
rowMapper
- the RowMapper which creates an object for each row
-
RowMapperResultSetExtractor
Create a new RowMapperResultSetExtractor.- Parameters:
rowMapper
- the RowMapper which creates an object for each rowrowsExpected
- the number of expected rows (just used for optimized collection handling)
-
-
Method Details
-
extractData
- Throws:
SQLException
-