org.springframework.batch.item.database.builder

## 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 the `HibernatePagingItemReader`. When configuring, only one of the following should be provided:
  - `queryString(String)`
  - `queryName(String)`
  - `queryProvider(HibernateQueryProvider)`
  Since:
    4.0
  Author:
    Michael Minella, Glenn Renfro, Mahmoud Ben Hassine
  See Also:
    `HibernatePagingItemReader`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HibernatePagingItemReaderBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `HibernatePagingItemReader<T>` | `build()` Returns a fully constructed `HibernatePagingItemReader`.
    `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 the `ExecutionContext`.
    `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<T> 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 the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    `HibernatePagingItemReaderBuilder<T>` | `sessionFactory(org.hibernate.SessionFactory sessionFactory)` The Hibernate `SessionFactory` to execute the query against.
    `HibernatePagingItemReaderBuilder<T>` | `useSatelessSession(boolean useStatelessSession)` Deprecated. This method is deprecated in favor of `useStatelessSession(boolean)` and will be removed in a future version.
    `HibernatePagingItemReaderBuilder<T>` | `useStatelessSession(boolean useStatelessSession)` Indicator for whether to use a `StatelessSession` (`true`) or a `Session` (`false`).

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HibernatePagingItemReaderBuilder

          public HibernatePagingItemReaderBuilder()

  - ### Method Detail

    - #### saveState

          public HibernatePagingItemReaderBuilder<T> saveState(boolean saveState)

      Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` 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 the `ExecutionContext`. Required if `saveState(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<T> queryProvider)

      A query provider. This should be set only if `queryString(String)` and `queryName(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 if `queryProvider(HibernateQueryProvider)` and `queryName(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 Hibernate `SessionFactory` 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 of `useStatelessSession(boolean)` and will be removed in a future version.
      Indicator for whether to use a `StatelessSession` (`true`) or a `Session` (`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 a `StatelessSession` (`true`) or a `Session` (`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 constructed `HibernatePagingItemReader`.
      Returns:
        a new `HibernatePagingItemReader`