Top Description Fields Constructors Methods
liquibase.executor.jvm

public Class RowMapperResultSetExtractor

extends Object
implements ResultSetExtractor
Class Inheritance
All Implemented Interfaces
liquibase.executor.jvm.ResultSetExtractor
Known Direct Subclasses
liquibase.executor.jvm.RowMapperNotNullConstraintsResultSetExtractor
Annotations
@SuppressWarnings:unchecked
Imports
java.sql.ResultSet, .SQLException, java.util.ArrayList, .List

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));

Author
Spring Framework
See Also
RowMapper, liquibase.executor.Executor

Field Summary

Modifier and TypeField and Description
protected final RowMapper
protected final int

Constructor Summary

AccessConstructor 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.

Method Summary

Modifier and TypeMethod 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.executor.jvm.ResultSetExtractor.extractData.

Implementations must implement this method to process the entire ResultSet.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

rowMapperback to summary
protected final RowMapper rowMapper
rowsExpectedback to summary
protected final int rowsExpected

Constructor Detail

RowMapperResultSetExtractorback to summary
public RowMapperResultSetExtractor(RowMapper rowMapper)

Create a new RowMapperResultSetExtractor.

Parameters
rowMapper:RowMapper

the RowMapper which creates an object for each row

RowMapperResultSetExtractorback to summary
public RowMapperResultSetExtractor(RowMapper rowMapper, int rowsExpected)

Create a new RowMapperResultSetExtractor.

Parameters
rowMapper:RowMapper

the RowMapper which creates an object for each row

rowsExpected:int

the number of expected rows (just used for optimized collection handling)

Method Detail

extractDataback to summary
public Object extractData(ResultSet rs) throws SQLException

Implements liquibase.executor.jvm.ResultSetExtractor.extractData.

Doc from liquibase.executor.jvm.ResultSetExtractor.extractData.

Implementations must implement this method to process the entire ResultSet.

Parameters
rs:ResultSet

ResultSet to extract data from. Implementations should not close this: it will be closed by the calling JdbcTemplate.

Returns:Object

an arbitrary result object, or null if none (the extractor will typically be stateful in the latter case).

Annotations
@Override
Exceptions
SQLException:
if a SQLException is encountered getting column values or navigating (that is, there's no need to catch SQLException)