Class HibernatePagingItemReaderBuilder<T>
- java.lang.Object
- org.springframework.batch.item.database.builder.HibernatePagingItemReaderBuilder<T>
public class HibernatePagingItemReaderBuilder<T> extends java.lang.Object
A builder for theHibernatePagingItemReader
. When configuring, only one of the following should be provided:- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro, Mahmoud Ben Hassine
- See Also:
HibernatePagingItemReader
Constructor Summary
Constructors Constructor Description HibernatePagingItemReaderBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HibernatePagingItemReader<T>
build()
Returns a fully constructedHibernatePagingItemReader
.HibernatePagingItemReaderBuilder<T>
currentItemCount(int currentItemCount)
Index for the current item.HibernatePagingItemReaderBuilder<T>
fetchSize(int fetchSize)
Fetch size used internally by Hibernate to limit amount of data fetched from database per round trip.HibernatePagingItemReaderBuilder<T>
maxItemCount(int maxItemCount)
Configure the max number of items to be read.HibernatePagingItemReaderBuilder<T>
name(java.lang.String name)
The name used to calculate the key within theExecutionContext
.HibernatePagingItemReaderBuilder<T>
pageSize(int pageSize)
The number of records to request per page/query.HibernatePagingItemReaderBuilder<T>
parameterValues(java.util.Map<java.lang.String,java.lang.Object> parameterValues)
A map of parameter values to be set on the query.HibernatePagingItemReaderBuilder<T>
queryName(java.lang.String queryName)
The name of the Hibernate named query to be executed for this reader.HibernatePagingItemReaderBuilder<T>
queryProvider(HibernateQueryProvider queryProvider)
A query provider.HibernatePagingItemReaderBuilder<T>
queryString(java.lang.String queryString)
The HQL query string to execute.HibernatePagingItemReaderBuilder<T>
saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.HibernatePagingItemReaderBuilder<T>
sessionFactory(org.hibernate.SessionFactory sessionFactory)
The HibernateSessionFactory
to execute the query against.HibernatePagingItemReaderBuilder<T>
useSatelessSession(boolean useStatelessSession)
Deprecated.This method is deprecated in favor ofuseStatelessSession(boolean)
and will be removed in a future version.HibernatePagingItemReaderBuilder<T>
useStatelessSession(boolean useStatelessSession)
Indicator for whether to use aStatelessSession
(true
) or aSession
(false
).
Method Detail
saveState
public HibernatePagingItemReaderBuilder<T> saveState(boolean saveState)
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
name
public HibernatePagingItemReaderBuilder<T> name(java.lang.String 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:
ItemStreamSupport.setName(String)
maxItemCount
public HibernatePagingItemReaderBuilder<T> maxItemCount(int 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:
AbstractItemCountingItemStreamItemReader.setMaxItemCount(int)
currentItemCount
public HibernatePagingItemReaderBuilder<T> currentItemCount(int 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:
AbstractItemCountingItemStreamItemReader.setCurrentItemCount(int)
pageSize
public HibernatePagingItemReaderBuilder<T> pageSize(int 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:
AbstractPagingItemReader.setPageSize(int)
parameterValues
public HibernatePagingItemReaderBuilder<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.- Parameters:
parameterValues
- map of values- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setParameterValues(Map)
queryName
public HibernatePagingItemReaderBuilder<T> queryName(java.lang.String queryName)
The name of the Hibernate named query to be executed for this reader.- Parameters:
queryName
- name of the query to execute- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setQueryName(String)
fetchSize
public HibernatePagingItemReaderBuilder<T> fetchSize(int fetchSize)
Fetch size used internally by Hibernate to limit amount of data fetched from database per round trip.- Parameters:
fetchSize
- number of records- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setFetchSize(int)
queryProvider
public HibernatePagingItemReaderBuilder<T> queryProvider(HibernateQueryProvider queryProvider)
A query provider. This should be set only ifqueryString(String)
andqueryName(String)
have not been set.- Parameters:
queryProvider
- the query provider- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setQueryProvider(HibernateQueryProvider)
queryString
public HibernatePagingItemReaderBuilder<T> queryString(java.lang.String queryString)
The HQL query string to execute. This should only be set ifqueryProvider(HibernateQueryProvider)
andqueryName(String)
have not been set.- Parameters:
queryString
- the HQL query- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setQueryString(String)
sessionFactory
public HibernatePagingItemReaderBuilder<T> sessionFactory(org.hibernate.SessionFactory sessionFactory)
The HibernateSessionFactory
to execute the query against.- Parameters:
sessionFactory
- the session factory- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setSessionFactory(SessionFactory)
useSatelessSession
@Deprecated public HibernatePagingItemReaderBuilder<T> useSatelessSession(boolean useStatelessSession)
Deprecated.This method is deprecated in favor ofuseStatelessSession(boolean)
and will be removed in a future version.Indicator for whether to use aStatelessSession
(true
) or aSession
(false
).- Parameters:
useStatelessSession
- Defaults to false- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setUseStatelessSession(boolean)
useStatelessSession
public HibernatePagingItemReaderBuilder<T> useStatelessSession(boolean useStatelessSession)
Indicator for whether to use aStatelessSession
(true
) or aSession
(false
).- Parameters:
useStatelessSession
- Defaults to false- Returns:
- this instance for method chaining
- See Also:
HibernatePagingItemReader.setUseStatelessSession(boolean)
build
public HibernatePagingItemReader<T> build()
Returns a fully constructedHibernatePagingItemReader
.- Returns:
- a new
HibernatePagingItemReader