类 JpaPagingItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.database.builder.JpaPagingItemReaderBuilder<T>
public class JpaPagingItemReaderBuilder<T> extends java.lang.Object
Creates a fully qualified JpaPagingItemReader.- 从以下版本开始:
- 4.0
- 作者:
- Michael Minella, Glenn Renfro
构造器概要
构造器 构造器 说明 JpaPagingItemReaderBuilder()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 JpaPagingItemReader<T>
build()
Returns a fully constructedJpaPagingItemReader
.JpaPagingItemReaderBuilder<T>
currentItemCount(int currentItemCount)
Index for the current item.JpaPagingItemReaderBuilder<T>
entityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
TheEntityManagerFactory
to be used for executing the configuredqueryString
.JpaPagingItemReaderBuilder<T>
maxItemCount(int maxItemCount)
Configure the max number of items to be read.JpaPagingItemReaderBuilder<T>
name(java.lang.String name)
The name used to calculate the key within theExecutionContext
.JpaPagingItemReaderBuilder<T>
pageSize(int pageSize)
The number of records to request per page/query.JpaPagingItemReaderBuilder<T>
parameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)
A map of parameter values to be set on the query.JpaPagingItemReaderBuilder<T>
queryProvider(JpaQueryProvider queryProvider)
A query provider.JpaPagingItemReaderBuilder<T>
queryString(java.lang.String queryString)
The HQL query string to execute.JpaPagingItemReaderBuilder<T>
saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.JpaPagingItemReaderBuilder<T>
transacted(boolean transacted)
Indicates if a transaction should be created around the read (true by default).
构造器详细资料
JpaPagingItemReaderBuilder
public JpaPagingItemReaderBuilder()
方法详细资料
saveState
public JpaPagingItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- 参数:
saveState
- defaults to true- 返回:
- The current instance of the builder.
name
public JpaPagingItemReaderBuilder<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 JpaPagingItemReaderBuilder<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 JpaPagingItemReaderBuilder<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)
pageSize
public JpaPagingItemReaderBuilder<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)
parameterValues
public JpaPagingItemReaderBuilder<T> parameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)
A map of parameter values to be set on the query. The key of the map is the name of the parameter to be set with the value being the value to be set.- 参数:
parameterValues
- map of values- 返回:
- this instance for method chaining
- 另请参阅:
JpaPagingItemReader.setParameterValues(Map)
queryProvider
public JpaPagingItemReaderBuilder<T> queryProvider(JpaQueryProvider queryProvider)
A query provider. This should be set only ifqueryString(String)
have not been set.- 参数:
queryProvider
- the query provider- 返回:
- this instance for method chaining
- 另请参阅:
JpaPagingItemReader.setQueryProvider(JpaQueryProvider)
queryString
public JpaPagingItemReaderBuilder<T> queryString(java.lang.String queryString)
The HQL query string to execute. This should only be set ifqueryProvider(JpaQueryProvider)
has not been set.- 参数:
queryString
- the HQL query- 返回:
- this instance for method chaining
- 另请参阅:
JpaPagingItemReader.setQueryString(String)
transacted
public JpaPagingItemReaderBuilder<T> transacted(boolean transacted)
Indicates if a transaction should be created around the read (true by default). Can be set to false in cases where JPA implementation doesn't support a particular transaction, however this may cause object inconsistency in the EntityManagerFactory.- 参数:
transacted
- defaults to true- 返回:
- this instance for method chaining
- 另请参阅:
JpaPagingItemReader.setTransacted(boolean)
entityManagerFactory
public JpaPagingItemReaderBuilder<T> entityManagerFactory(javax.persistence.EntityManagerFactory entityManagerFactory)
TheEntityManagerFactory
to be used for executing the configuredqueryString
.- 参数:
entityManagerFactory
-EntityManagerFactory
used to createEntityManager
- 返回:
- this instance for method chaining
build
public JpaPagingItemReader<T> build()
Returns a fully constructedJpaPagingItemReader
.- 返回:
- a new
JpaPagingItemReader