Package org.springframework.batch.item.database.builder

# Class StoredProcedureItemReaderBuilder<T>

java.lang.Object
org.springframework.batch.item.database.builder.StoredProcedureItemReaderBuilder<T>

public class StoredProcedureItemReaderBuilder<T> extends Object
A fluent builder API for the configuration of a `StoredProcedureItemReader`.

Since:
  4.0.0
Author:
  Michael Minella, Mahmoud Ben Hassine, Drummond Dawson
See Also:
  - `StoredProcedureItemReader`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `VALUE_NOT_SET`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StoredProcedureItemReaderBuilder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `StoredProcedureItemReader<T>`
  `build()`
  Validates configuration and builds a new reader instance
  `StoredProcedureItemReaderBuilder<T>`
  `currentItemCount(int currentItemCount)`
  Index for the current item.
  `StoredProcedureItemReaderBuilder<T>`
  `dataSource(DataSource dataSource)`
  The `DataSource` to read from
  `StoredProcedureItemReaderBuilder<T>`
  `driverSupportsAbsolute(boolean driverSupportsAbsolute)`
  Indicates if the JDBC driver supports setting the absolute row on the `ResultSet`.
  `StoredProcedureItemReaderBuilder<T>`
  `fetchSize(int fetchSize)`
  A hint to the driver as to how many rows to return with each fetch.
  `StoredProcedureItemReaderBuilder<T>`
  `function()`
  Indicates the stored procedure is a function
  `StoredProcedureItemReaderBuilder<T>`
  `ignoreWarnings(boolean ignoreWarnings)`
  Indicates if SQL warnings should be ignored or if an exception should be thrown.
  `StoredProcedureItemReaderBuilder<T>`
  `maxItemCount(int maxItemCount)`
  Configure the max number of items to be read.
  `StoredProcedureItemReaderBuilder<T>`
  `maxRows(int maxRows)`
  The max number of rows the `ResultSet` can contain
  `StoredProcedureItemReaderBuilder<T>`
  `name(String name)`
  The name used to calculate the key within the `ExecutionContext`.
  `StoredProcedureItemReaderBuilder<T>`
  `parameters(org.springframework.jdbc.core.SqlParameter... parameters)`
  SQL parameters to be set when executing the stored procedure
  `StoredProcedureItemReaderBuilder<T>`
  `preparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter)`
  Configures the provided `PreparedStatementSetter` to be used to populate any arguments in the SQL query to be executed for the reader.
  `StoredProcedureItemReaderBuilder<T>`
  `procedureName(String procedureName)`
  The name of the stored procedure to execute
  `StoredProcedureItemReaderBuilder<T>`
  `queryTimeout(int queryTimeout)`
  The time in milliseconds for the query to timeout
  `StoredProcedureItemReaderBuilder<T>`
  `refCursorPosition(int refCursorPosition)`
  The parameter position of the REF CURSOR.
  `StoredProcedureItemReaderBuilder<T>`
  `rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)`
  The `RowMapper` used to map the results of the cursor to each item.
  `StoredProcedureItemReaderBuilder<T>`
  `saveState(boolean saveState)`
  Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
  `StoredProcedureItemReaderBuilder<T>`
  `useSharedExtendedConnection(boolean useSharedExtendedConnection)`
  Indicates that the connection used for the cursor is being used by all other processing, therefor part of the same transaction.
  `StoredProcedureItemReaderBuilder<T>`
  `verifyCursorPosition(boolean verifyCursorPosition)`
  Indicates if the reader should verify the current position of the `ResultSet` after being passed to the `RowMapper`.

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

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

- ## Field Details

  - ### VALUE_NOT_SET

    public static final int VALUE_NOT_SET
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### StoredProcedureItemReaderBuilder

    public StoredProcedureItemReaderBuilder()

- ## Method Details

  - ### saveState

    public StoredProcedureItemReaderBuilder<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 StoredProcedureItemReaderBuilder<T> name(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 StoredProcedureItemReaderBuilder<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 StoredProcedureItemReaderBuilder<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)`

  - ### dataSource

    public StoredProcedureItemReaderBuilder<T> dataSource(DataSource dataSource)
    The `DataSource` to read from
    Parameters:
      `dataSource` - a relational data base
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setDataSource(DataSource)`

  - ### fetchSize

    public StoredProcedureItemReaderBuilder<T> fetchSize(int fetchSize)
    A hint to the driver as to how many rows to return with each fetch.
    Parameters:
      `fetchSize` - the hint
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setFetchSize(int)`

  - ### maxRows

    public StoredProcedureItemReaderBuilder<T> maxRows(int maxRows)
    The max number of rows the `ResultSet` can contain
    Parameters:
      `maxRows` - the max
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setMaxRows(int)`

  - ### queryTimeout

    public StoredProcedureItemReaderBuilder<T> queryTimeout(int queryTimeout)
    The time in milliseconds for the query to timeout
    Parameters:
      `queryTimeout` - timeout
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setQueryTimeout(int)`

  - ### ignoreWarnings

    public StoredProcedureItemReaderBuilder<T> ignoreWarnings(boolean ignoreWarnings)
    Indicates if SQL warnings should be ignored or if an exception should be thrown.
    Parameters:
      `ignoreWarnings` - indicator. Defaults to true
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setIgnoreWarnings(boolean)`

  - ### verifyCursorPosition

    public StoredProcedureItemReaderBuilder<T> verifyCursorPosition(boolean verifyCursorPosition)
    Indicates if the reader should verify the current position of the `ResultSet` after being passed to the `RowMapper`. Defaults to true.
    Parameters:
      `verifyCursorPosition` - indicator
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setVerifyCursorPosition(boolean)`

  - ### driverSupportsAbsolute

    public StoredProcedureItemReaderBuilder<T> driverSupportsAbsolute(boolean driverSupportsAbsolute)
    Indicates if the JDBC driver supports setting the absolute row on the `ResultSet`.
    Parameters:
      `driverSupportsAbsolute` - indicator
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setDriverSupportsAbsolute(boolean)`

  - ### useSharedExtendedConnection

    public StoredProcedureItemReaderBuilder<T> useSharedExtendedConnection(boolean useSharedExtendedConnection)
    Indicates that the connection used for the cursor is being used by all other processing, therefor part of the same transaction.
    Parameters:
      `useSharedExtendedConnection` - indicator
    Returns:
      this instance for method chaining
    See Also:
      - `AbstractCursorItemReader.setUseSharedExtendedConnection(boolean)`

  - ### preparedStatementSetter

    public StoredProcedureItemReaderBuilder<T> preparedStatementSetter(org.springframework.jdbc.core.PreparedStatementSetter preparedStatementSetter)
    Configures the provided `PreparedStatementSetter` to be used to populate any arguments in the SQL query to be executed for the reader.
    Parameters:
      `preparedStatementSetter` - setter
    Returns:
      this instance for method chaining
    See Also:
      - `StoredProcedureItemReader.setPreparedStatementSetter(PreparedStatementSetter)`

  - ### rowMapper

    public StoredProcedureItemReaderBuilder<T> rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)
    The `RowMapper` used to map the results of the cursor to each item.
    Parameters:
      `rowMapper` - `RowMapper`
    Returns:
      this instance for method chaining
    See Also:
      - `StoredProcedureItemReader.setRowMapper(RowMapper)`

  - ### procedureName

    public StoredProcedureItemReaderBuilder<T> procedureName(String procedureName)
    The name of the stored procedure to execute
    Parameters:
      `procedureName` - name of the procedure
    Returns:
      this instance for method chaining
    See Also:
      - `StoredProcedureItemReader.setProcedureName(String)`

  - ### parameters

    public StoredProcedureItemReaderBuilder<T> parameters(org.springframework.jdbc.core.SqlParameter... parameters)
    SQL parameters to be set when executing the stored procedure
    Parameters:
      `parameters` - parameters to be set
    Returns:
      this instance for method chaining
    See Also:
      - `StoredProcedureItemReader.setParameters(SqlParameter[])`

  - ### function

    public StoredProcedureItemReaderBuilder<T> function()
    Indicates the stored procedure is a function
    Returns:
      this instance for method chaining
    See Also:
      - `StoredProcedureItemReader.setFunction(boolean)`

  - ### refCursorPosition

    public StoredProcedureItemReaderBuilder<T> refCursorPosition(int refCursorPosition)
    The parameter position of the REF CURSOR. Only used for Oracle and PostgreSQL that use REF CURSORs. For any other database, this should remain as the default (0).
    Parameters:
      `refCursorPosition` - the parameter position
    Returns:
      this instance for method chaining
    See Also:
      - `StoredProcedureItemReader.setRefCursorPosition(int)`

  - ### build

    public StoredProcedureItemReader<T> build()
    Validates configuration and builds a new reader instance
    Returns:
      a fully constructed `StoredProcedureItemReader`