org.springframework.batch.item.database.builder

## Class JdbcCursorItemReaderBuilder<T>

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

-     public class JdbcCursorItemReaderBuilder<T>
      extends java.lang.Object

  Builder for the `JdbcCursorItemReader`
  Since:
    4.0
  Author:
    Michael Minella, Glenn Renfro, Drummond Dawson, Mahmoud Ben Hassine

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JdbcCursorItemReaderBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JdbcCursorItemReaderBuilder<T>` | `beanRowMapper(java.lang.Class<T> mappedClass)` Creates a `BeanPropertyRowMapper` to be used as your `RowMapper`.
    `JdbcCursorItemReader<T>` | `build()` Validates configuration and builds a new reader instance.
    `JdbcCursorItemReaderBuilder<T>` | `currentItemCount(int currentItemCount)` Index for the current item.
    `JdbcCursorItemReaderBuilder<T>` | `dataSource(javax.sql.DataSource dataSource)` The `DataSource` to read from
    `JdbcCursorItemReaderBuilder<T>` | `driverSupportsAbsolute(boolean driverSupportsAbsolute)` Indicates if the JDBC driver supports setting the absolute row on the `ResultSet`.
    `JdbcCursorItemReaderBuilder<T>` | `fetchSize(int fetchSize)` A hint to the driver as to how many rows to return with each fetch.
    `JdbcCursorItemReaderBuilder<T>` | `ignoreWarnings(boolean ignoreWarnings)`
    `JdbcCursorItemReaderBuilder<T>` | `maxItemCount(int maxItemCount)` Configure the max number of items to be read.
    `JdbcCursorItemReaderBuilder<T>` | `maxRows(int maxRows)` The max number of rows the `ResultSet` can contain
    `JdbcCursorItemReaderBuilder<T>` | `name(java.lang.String name)` The name used to calculate the key within the `ExecutionContext`.
    `JdbcCursorItemReaderBuilder<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.
    `JdbcCursorItemReaderBuilder<T>` | `queryArguments(java.util.List<?> args)` Configures a `PreparedStatementSetter` that will use the List as the values to be set on the query to be executed for this reader.
    `JdbcCursorItemReaderBuilder<T>` | `queryArguments(java.lang.Object... args)` Configures a `PreparedStatementSetter` that will use the array as the values to be set on the query to be executed for this reader.
    `JdbcCursorItemReaderBuilder<T>` | `queryArguments(java.lang.Object[] args, int[] types)` Configures a `PreparedStatementSetter` that will use the Object [] as the values to be set on the query to be executed for this reader.
    `JdbcCursorItemReaderBuilder<T>` | `queryTimeout(int queryTimeout)` The time in milliseconds for the query to timeout
    `JdbcCursorItemReaderBuilder<T>` | `rowMapper(org.springframework.jdbc.core.RowMapper<T> rowMapper)` The `RowMapper` used to map the results of the cursor to each item.
    `JdbcCursorItemReaderBuilder<T>` | `saveState(boolean saveState)` Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    `JdbcCursorItemReaderBuilder<T>` | `sql(java.lang.String sql)` The query to be executed for this reader
    `JdbcCursorItemReaderBuilder<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.
    `JdbcCursorItemReaderBuilder<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`

- - ### Constructor Detail

    - #### JdbcCursorItemReaderBuilder

          public JdbcCursorItemReaderBuilder()

  - ### Method Detail

    - #### saveState

          public JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<T> dataSource(javax.sql.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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<T> ignoreWarnings(boolean ignoreWarnings)

    - #### verifyCursorPosition

          public JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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 JdbcCursorItemReaderBuilder<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:
        `JdbcCursorItemReader.setPreparedStatementSetter(PreparedStatementSetter)`

    - #### queryArguments

          public JdbcCursorItemReaderBuilder<T> queryArguments(java.lang.Object... args)

      Configures a `PreparedStatementSetter` that will use the array as the values to be set on the query to be executed for this reader.
      Parameters:
        `args` - values to set on the reader query
      Returns:
        this instance for method chaining

    - #### queryArguments

          public JdbcCursorItemReaderBuilder<T> queryArguments(java.lang.Object[] args,
                                                               int[] types)

      Configures a `PreparedStatementSetter` that will use the Object [] as the values to be set on the query to be executed for this reader. The int[] will provide the types (`Types`) for each of the values provided.
      Parameters:
        `args` - values to set on the query
        `types` - the type for each value in the args array
      Returns:
        this instance for method chaining

    - #### queryArguments

          public JdbcCursorItemReaderBuilder<T> queryArguments(java.util.List<?> args)

      Configures a `PreparedStatementSetter` that will use the List as the values to be set on the query to be executed for this reader.
      Parameters:
        `args` - values to set on the query
      Returns:
        this instance for method chaining

    - #### sql

          public JdbcCursorItemReaderBuilder<T> sql(java.lang.String sql)

      The query to be executed for this reader
      Parameters:
        `sql` - query
      Returns:
        this instance for method chaining
      See Also:
        `JdbcCursorItemReader.setSql(String)`

    - #### rowMapper

          public JdbcCursorItemReaderBuilder<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:
        `JdbcCursorItemReader.setRowMapper(RowMapper)`

    - #### beanRowMapper

          public JdbcCursorItemReaderBuilder<T> beanRowMapper(java.lang.Class<T> mappedClass)

      Creates a `BeanPropertyRowMapper` to be used as your `RowMapper`.
      Parameters:
        `mappedClass` - the class for the row mapper
      Returns:
        this instance for method chaining
      See Also:
        `BeanPropertyRowMapper`

    - #### build

          public JdbcCursorItemReader<T> build()

      Validates configuration and builds a new reader instance.
      Returns:
        a fully constructed `JdbcCursorItemReader`