Class JdbcPagingItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.database.builder.JdbcPagingItemReaderBuilder<T>
This is a builder for the
JdbcPagingItemReader. When configuring, either a
PagingQueryProvider or the SQL fragments should be provided. If the SQL
fragments are provided, the metadata from the provided DataSource will be used
to create a PagingQueryProvider for you. If both are provided, the PagingQueryProvider
will be used.- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro, Drummond Dawson
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbeanRowMapper(Class<T> mappedClass) Creates aBeanPropertyRowMapperto be used as yourRowMapper.build()Provides a completely built instance of theJdbcPagingItemReadercurrentItemCount(int currentItemCount) Index for the current item.dataSource(DataSource dataSource) TheDataSourceto query against.fetchSize(int fetchSize) A hint to the underlying RDBMS as to how many records to return with each fetch.fromClause(String fromClause) The SQLFROMclause for a db specificPagingQueryProvider.groupClause(String groupClause) The SQLGROUP BYclause for a db specific @PagingQueryProvider.maxItemCount(int maxItemCount) Configure the max number of items to be read.The name used to calculate the key within theExecutionContext.pageSize(int pageSize) The number of records to request per page/query.parameterValues(Map<String, Object> parameterValues) AMapof values to set on the SQL's prepared statement.queryProvider(PagingQueryProvider provider) APagingQueryProviderto provide the queries required.TheRowMapperused to map the query results to objects.saveState(boolean saveState) Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.selectClause(String selectClause) The SQLSELECTclause for a db specificPagingQueryProvider.The keys to sort by.whereClause(String whereClause) The SQLWHEREclause for a db specificPagingQueryProvider.
-
Constructor Details
-
JdbcPagingItemReaderBuilder
public JdbcPagingItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- Parameters:
saveState- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext. Required ifsaveState(boolean)is set to true.- Parameters:
name- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
-
maxItemCount
Configure the max number of items to be read.- Parameters:
maxItemCount- the max items to be read- Returns:
- The current instance of the builder.
- See Also:
-
currentItemCount
Index for the current item. Used on restarts to indicate where to start from.- Parameters:
currentItemCount- current index- Returns:
- this instance for method chaining
- See Also:
-
dataSource
TheDataSourceto query against. Required.- Parameters:
dataSource- theDataSource- Returns:
- this instance for method chaining
- See Also:
-
fetchSize
A hint to the underlying RDBMS as to how many records to return with each fetch.- Parameters:
fetchSize- number of records- Returns:
- this instance for method chaining
- See Also:
-
rowMapper
public JdbcPagingItemReaderBuilder<T> rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper) TheRowMapperused to map the query results to objects. Required.- Parameters:
rowMapper- aRowMapperimplementation- Returns:
- this instance for method chaining
- See Also:
-
beanRowMapper
Creates aBeanPropertyRowMapperto be used as yourRowMapper.- Parameters:
mappedClass- the class for the row mapper- Returns:
- this instance for method chaining
- See Also:
-
BeanPropertyRowMapper
-
parameterValues
AMapof values to set on the SQL's prepared statement.- Parameters:
parameterValues- Map of values- Returns:
- this instance for method chaining
- See Also:
-
pageSize
The number of records to request per page/query. Defaults to 10. Must be greater than zero.- Parameters:
pageSize- number of items- Returns:
- this instance for method chaining
- See Also:
-
groupClause
The SQLGROUP BYclause for a db specific @PagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- Parameters:
groupClause- the SQL clause- Returns:
- this instance for method chaining
- See Also:
-
selectClause
The SQLSELECTclause for a db specificPagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- Parameters:
selectClause- the SQL clause- Returns:
- this instance for method chaining
- See Also:
-
fromClause
The SQLFROMclause for a db specificPagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- Parameters:
fromClause- the SQL clause- Returns:
- this instance for method chaining
- See Also:
-
whereClause
The SQLWHEREclause for a db specificPagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- Parameters:
whereClause- the SQL clause- Returns:
- this instance for method chaining
- See Also:
-
sortKeys
The keys to sort by. These keys must create a unique key.- Parameters:
sortKeys- keys to sort by and the direction for each.- Returns:
- this instance for method chaining
- See Also:
-
queryProvider
APagingQueryProviderto provide the queries required. If provided, the SQL fragments configured viaselectClause(String),fromClause(String),whereClause(String),groupClause, andsortKeys(Map)are ignored.- Parameters:
provider- the db specific query provider- Returns:
- this instance for method chaining
- See Also:
-
build
Provides a completely built instance of theJdbcPagingItemReader- Returns:
- a
JdbcPagingItemReader
-