Class HibernatePagingItemReaderBuilder<T>
java.lang.Object
org.springframework.batch.item.database.builder.HibernatePagingItemReaderBuilder<T>
A builder for the
HibernatePagingItemReader
. When configuring, only one of the
following should be provided:
- Since:
- 4.0
- Author:
- Michael Minella, Glenn Renfro, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Returns a fully constructedHibernatePagingItemReader
.currentItemCount
(int currentItemCount) Index for the current item.fetchSize
(int fetchSize) Fetch size used internally by Hibernate to limit amount of data fetched from database per round trip.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) A map of parameter values to be set on the query.The name of the Hibernate named query to be executed for this reader.queryProvider
(HibernateQueryProvider<T> queryProvider) A query provider.queryString
(String queryString) The HQL query string to execute.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.sessionFactory
(org.hibernate.SessionFactory sessionFactory) The HibernateSessionFactory
to execute the query against.useStatelessSession
(boolean useStatelessSession) Indicator for whether to use aStatelessSession
(true
) or aSession
(false
).
-
Constructor Details
-
HibernatePagingItemReaderBuilder
public HibernatePagingItemReaderBuilder()
-
-
Method Details
-
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
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:
-
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:
-
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:
-
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:
-
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:
-
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:
-
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:
-
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:
-
useStatelessSession
Indicator for whether to use aStatelessSession
(true
) or aSession
(false
).- Parameters:
useStatelessSession
- Defaults to false- Returns:
- this instance for method chaining
- See Also:
-
build
Returns a fully constructedHibernatePagingItemReader
.- Returns:
- a new
HibernatePagingItemReader
-