org.springframework.batch.item.database.builder

## Class JdbcBatchItemWriterBuilder<T>

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

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

  A builder implementation for the `JdbcBatchItemWriter`.
  Since:
    4.0
  Author:
    Michael Minella
  See Also:
    `JdbcBatchItemWriter`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JdbcBatchItemWriterBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JdbcBatchItemWriterBuilder<T>` | `assertUpdates(boolean assertUpdates)` If set to true, confirms that every insert results in the update of at least one row in the database.
    `JdbcBatchItemWriterBuilder<T>` | `beanMapped()` Creates a `BeanPropertyItemSqlParameterSourceProvider` to be used as your `ItemSqlParameterSourceProvider`.
    `JdbcBatchItemWriter<T>` | `build()` Validates configuration and builds the `JdbcBatchItemWriter`.
    `JdbcBatchItemWriterBuilder<T>` | `columnMapped()` Creates a `ColumnMapItemPreparedStatementSetter` to be used as your `ItemPreparedStatementSetter`.
    `JdbcBatchItemWriterBuilder<T>` | `dataSource(javax.sql.DataSource dataSource)` Configure the `DataSource` to be used.
    `JdbcBatchItemWriterBuilder<T>` | `itemPreparedStatementSetter(ItemPreparedStatementSetter<T> itemPreparedStatementSetter)` Configures a `ItemPreparedStatementSetter` for use by the writer.
    `JdbcBatchItemWriterBuilder<T>` | `itemSqlParameterSourceProvider(ItemSqlParameterSourceProvider<T> itemSqlParameterSourceProvider)` Configures a `ItemSqlParameterSourceProvider` for use by the writer.
    `JdbcBatchItemWriterBuilder<T>` | `namedParametersJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations namedParameterJdbcOperations)` The `NamedParameterJdbcOperations` instance to use.
    `JdbcBatchItemWriterBuilder<T>` | `sql(java.lang.String sql)` Set the SQL statement to be used for each item's updates.

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

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

- - ### Constructor Detail

    - #### JdbcBatchItemWriterBuilder

          public JdbcBatchItemWriterBuilder()

  - ### Method Detail

    - #### dataSource

          public JdbcBatchItemWriterBuilder<T> dataSource(javax.sql.DataSource dataSource)

      Configure the `DataSource` to be used.
      Parameters:
        `dataSource` - the DataSource
      Returns:
        The current instance of the builder for chaining.
      See Also:
        `JdbcBatchItemWriter.setDataSource(DataSource)`

    - #### assertUpdates

          public JdbcBatchItemWriterBuilder<T> assertUpdates(boolean assertUpdates)

      If set to true, confirms that every insert results in the update of at least one row in the database. Defaults to true.
      Parameters:
        `assertUpdates` - boolean indicator
      Returns:
        The current instance of the builder for chaining
      See Also:
        `JdbcBatchItemWriter.setAssertUpdates(boolean)`

    - #### sql

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

      Set the SQL statement to be used for each item's updates. This is a required field.
      Parameters:
        `sql` - SQL string
      Returns:
        The current instance of the builder for chaining
      See Also:
        `JdbcBatchItemWriter.setSql(String)`

    - #### itemPreparedStatementSetter

          public JdbcBatchItemWriterBuilder<T> itemPreparedStatementSetter(ItemPreparedStatementSetter<T> itemPreparedStatementSetter)

      Configures a `ItemPreparedStatementSetter` for use by the writer. This should only be used if `columnMapped()` isn't called.
      Parameters:
        `itemPreparedStatementSetter` - The `ItemPreparedStatementSetter`
      Returns:
        The current instance of the builder for chaining
      See Also:
        `JdbcBatchItemWriter.setItemPreparedStatementSetter(ItemPreparedStatementSetter)`

    - #### itemSqlParameterSourceProvider

          public JdbcBatchItemWriterBuilder<T> itemSqlParameterSourceProvider(ItemSqlParameterSourceProvider<T> itemSqlParameterSourceProvider)

      Configures a `ItemSqlParameterSourceProvider` for use by the writer. This should only be used if `beanMapped()` isn't called.
      Parameters:
        `itemSqlParameterSourceProvider` - The `ItemSqlParameterSourceProvider`
      Returns:
        The current instance of the builder for chaining
      See Also:
        `JdbcBatchItemWriter.setItemSqlParameterSourceProvider(ItemSqlParameterSourceProvider)`

    - #### namedParametersJdbcTemplate

          public JdbcBatchItemWriterBuilder<T> namedParametersJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations namedParameterJdbcOperations)

      The `NamedParameterJdbcOperations` instance to use. If one isn't provided, a `DataSource` is required.
      Parameters:
        `namedParameterJdbcOperations` - The template
      Returns:
        The current instance of the builder for chaining

    - #### columnMapped

          public JdbcBatchItemWriterBuilder<T> columnMapped()

      Creates a `ColumnMapItemPreparedStatementSetter` to be used as your `ItemPreparedStatementSetter`. NOTE: The item type for this `ItemWriter` must be castable to `Map<String,Object>>`.
      Returns:
        The current instance of the builder for chaining
      See Also:
        `ColumnMapItemPreparedStatementSetter`

    - #### beanMapped

          public JdbcBatchItemWriterBuilder<T> beanMapped()

      Creates a `BeanPropertyItemSqlParameterSourceProvider` to be used as your `ItemSqlParameterSourceProvider`.
      Returns:
        The current instance of the builder for chaining
      See Also:
        `BeanPropertyItemSqlParameterSourceProvider`

    - #### build

          public JdbcBatchItemWriter<T> build()

      Validates configuration and builds the `JdbcBatchItemWriter`.
      Returns:
        a `JdbcBatchItemWriter`