类 JdbcPagingItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.database.builder.JdbcPagingItemReaderBuilder<T>
public class JdbcPagingItemReaderBuilder<T> extends java.lang.Object
This is a builder for theJdbcPagingItemReader. When configuring, either aPagingQueryProvideror the SQL fragments should be provided. If the SQL fragments are provided, the metadata from the providedDataSourcewill be used to create a PagingQueryProvider for you. If both are provided, the PagingQueryProvider will be used.- 从以下版本开始:
- 4.0
- 作者:
- Michael Minella, Glenn Renfro
- 另请参阅:
JdbcPagingItemReader
构造器概要
构造器 构造器 说明 JdbcPagingItemReaderBuilder()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 JdbcPagingItemReader<T>build()Provides a completely built instance of theJdbcPagingItemReaderJdbcPagingItemReaderBuilder<T>currentItemCount(int currentItemCount)Index for the current item.JdbcPagingItemReaderBuilder<T>dataSource(javax.sql.DataSource dataSource)TheDataSourceto query against.JdbcPagingItemReaderBuilder<T>fetchSize(int fetchSize)A hint to the underlying RDBMS as to how many records to return with each fetch.JdbcPagingItemReaderBuilder<T>fromClause(java.lang.String fromClause)The SQLFROMclause for a db specificPagingQueryProvider.JdbcPagingItemReaderBuilder<T>groupClause(java.lang.String groupClause)The SQLGROUP BYclause for a db specific @PagingQueryProvider.JdbcPagingItemReaderBuilder<T>maxItemCount(int maxItemCount)Configure the max number of items to be read.JdbcPagingItemReaderBuilder<T>name(java.lang.String name)The name used to calculate the key within theExecutionContext.JdbcPagingItemReaderBuilder<T>pageSize(int pageSize)The number of records to request per page/query.JdbcPagingItemReaderBuilder<T>parameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)AMapof values to set on the SQL's prepared statement.JdbcPagingItemReaderBuilder<T>queryProvider(PagingQueryProvider provider)APagingQueryProviderto provide the queries required.JdbcPagingItemReaderBuilder<T>rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)TheRowMapperused to map the query results to objects.JdbcPagingItemReaderBuilder<T>saveState(boolean saveState)Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.JdbcPagingItemReaderBuilder<T>selectClause(java.lang.String selectClause)The SQLSELECTclause for a db specificPagingQueryProvider.JdbcPagingItemReaderBuilder<T>sortKeys(java.util.Map<java.lang.String,Order> sortKeys)The keys to sort by.JdbcPagingItemReaderBuilder<T>whereClause(java.lang.String whereClause)The SQLWHEREclause for a db specificPagingQueryProvider.
构造器详细资料
JdbcPagingItemReaderBuilder
public JdbcPagingItemReaderBuilder()
方法详细资料
saveState
public JdbcPagingItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupportshould be persisted within theExecutionContextfor restart purposes.- 参数:
saveState- defaults to true- 返回:
- The current instance of the builder.
name
public JdbcPagingItemReaderBuilder<T> name(java.lang.String name)
The name used to calculate the key within theExecutionContext. Required ifsaveState(boolean)is set to true.- 参数:
name- name of the reader instance- 返回:
- The current instance of the builder.
- 另请参阅:
ItemStreamSupport.setName(String)
maxItemCount
public JdbcPagingItemReaderBuilder<T> maxItemCount(int maxItemCount)
Configure the max number of items to be read.- 参数:
maxItemCount- the max items to be read- 返回:
- The current instance of the builder.
- 另请参阅:
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
currentItemCount
public JdbcPagingItemReaderBuilder<T> currentItemCount(int currentItemCount)
Index for the current item. Used on restarts to indicate where to start from.- 参数:
currentItemCount- current index- 返回:
- this instance for method chaining
- 另请参阅:
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
dataSource
public JdbcPagingItemReaderBuilder<T> dataSource(javax.sql.DataSource dataSource)
TheDataSourceto query against. Required.- 参数:
dataSource- theDataSource- 返回:
- this instance for method chaining
- 另请参阅:
JdbcPagingItemReader.setDataSource(DataSource)
fetchSize
public JdbcPagingItemReaderBuilder<T> fetchSize(int fetchSize)
A hint to the underlying RDBMS as to how many records to return with each fetch.- 参数:
fetchSize- number of records- 返回:
- this instance for method chaining
- 另请参阅:
JdbcPagingItemReader.setFetchSize(int)
rowMapper
public JdbcPagingItemReaderBuilder<T> rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)
TheRowMapperused to map the query results to objects. Required.- 参数:
rowMapper- aRowMapperimplementation- 返回:
- this instance for method chaining
- 另请参阅:
JdbcPagingItemReader.setRowMapper(RowMapper)
parameterValues
public JdbcPagingItemReaderBuilder<T> parameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)
AMapof values to set on the SQL's prepared statement.- 参数:
parameterValues- Map of values- 返回:
- this instance for method chaining
- 另请参阅:
JdbcPagingItemReader.setParameterValues(Map)
pageSize
public JdbcPagingItemReaderBuilder<T> pageSize(int pageSize)
The number of records to request per page/query. Defaults to 10. Must be greater than zero.- 参数:
pageSize- number of items- 返回:
- this instance for method chaining
- 另请参阅:
AbstractPagingItemReader.setPageSize(int)
groupClause
public JdbcPagingItemReaderBuilder<T> groupClause(java.lang.String groupClause)
The SQLGROUP BYclause for a db specific @PagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- 参数:
groupClause- the SQL clause- 返回:
- this instance for method chaining
- 另请参阅:
AbstractSqlPagingQueryProvider.setGroupClause(String)
selectClause
public JdbcPagingItemReaderBuilder<T> selectClause(java.lang.String selectClause)
The SQLSELECTclause for a db specificPagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- 参数:
selectClause- the SQL clause- 返回:
- this instance for method chaining
- 另请参阅:
AbstractSqlPagingQueryProvider.setSelectClause(String)
fromClause
public JdbcPagingItemReaderBuilder<T> fromClause(java.lang.String fromClause)
The SQLFROMclause for a db specificPagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- 参数:
fromClause- the SQL clause- 返回:
- this instance for method chaining
- 另请参阅:
AbstractSqlPagingQueryProvider.setFromClause(String)
whereClause
public JdbcPagingItemReaderBuilder<T> whereClause(java.lang.String whereClause)
The SQLWHEREclause for a db specificPagingQueryProvider. This is only used if a PagingQueryProvider is not provided.- 参数:
whereClause- the SQL clause- 返回:
- this instance for method chaining
- 另请参阅:
AbstractSqlPagingQueryProvider.setWhereClause(String)
sortKeys
public JdbcPagingItemReaderBuilder<T> sortKeys(java.util.Map<java.lang.String,Order> sortKeys)
The keys to sort by. These keys must create a unique key.- 参数:
sortKeys- keys to sort by and the direction for each.- 返回:
- this instance for method chaining
- 另请参阅:
AbstractSqlPagingQueryProvider.setSortKeys(Map)
queryProvider
public JdbcPagingItemReaderBuilder<T> queryProvider(PagingQueryProvider provider)
APagingQueryProviderto provide the queries required. If provided, the SQL fragments configured viaselectClause(String),fromClause(String),whereClause(String),groupClause, andsortKeys(Map)are ignored.- 参数:
provider- the db specific query provider- 返回:
- this instance for method chaining
- 另请参阅:
JdbcPagingItemReader.setQueryProvider(PagingQueryProvider)
build
public JdbcPagingItemReader<T> build()
Provides a completely built instance of theJdbcPagingItemReader- 返回:
- a
JdbcPagingItemReader