Class JdbcBatchItemWriterBuilder<T>
java.lang.Object
org.springframework.batch.item.database.builder.JdbcBatchItemWriterBuilder<T>
A builder implementation for the
JdbcBatchItemWriter.- Since:
- 4.0
- Author:
- Michael Minella, Stefano Cordio
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassertUpdates(boolean assertUpdates) If set to true, confirms that every insert results in the update of at least one row in the database.Creates aBeanPropertyItemSqlParameterSourceProviderto be used as yourItemSqlParameterSourceProvider.build()Validates configuration and builds theJdbcBatchItemWriter.Creates aColumnMapItemPreparedStatementSetterto be used as yourItemPreparedStatementSetter.dataSource(DataSource dataSource) Configure theDataSourceto be used.itemPreparedStatementSetter(ItemPreparedStatementSetter<T> itemPreparedStatementSetter) Configures aItemPreparedStatementSetterfor use by the writer.itemSqlParameterSourceProvider(ItemSqlParameterSourceProvider<T> itemSqlParameterSourceProvider) Configures aItemSqlParameterSourceProviderfor use by the writer.namedParametersJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations namedParameterJdbcOperations) TheNamedParameterJdbcOperationsinstance to use.Set the SQL statement to be used for each item's updates.
-
Constructor Details
-
JdbcBatchItemWriterBuilder
public JdbcBatchItemWriterBuilder()
-
-
Method Details
-
dataSource
Configure theDataSourceto be used.- Parameters:
dataSource- the DataSource- Returns:
- The current instance of the builder for chaining.
- See Also:
-
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:
-
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:
-
itemPreparedStatementSetter
public JdbcBatchItemWriterBuilder<T> itemPreparedStatementSetter(ItemPreparedStatementSetter<T> itemPreparedStatementSetter) Configures aItemPreparedStatementSetterfor use by the writer. This should only be used ifcolumnMapped()isn't called.- Parameters:
itemPreparedStatementSetter- TheItemPreparedStatementSetter- Returns:
- The current instance of the builder for chaining
- See Also:
-
itemSqlParameterSourceProvider
public JdbcBatchItemWriterBuilder<T> itemSqlParameterSourceProvider(ItemSqlParameterSourceProvider<T> itemSqlParameterSourceProvider) Configures aItemSqlParameterSourceProviderfor use by the writer. This should only be used ifbeanMapped()isn't called.- Parameters:
itemSqlParameterSourceProvider- TheItemSqlParameterSourceProvider- Returns:
- The current instance of the builder for chaining
- See Also:
-
namedParametersJdbcTemplate
public JdbcBatchItemWriterBuilder<T> namedParametersJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations namedParameterJdbcOperations) TheNamedParameterJdbcOperationsinstance to use. If one isn't provided, aDataSourceis required.- Parameters:
namedParameterJdbcOperations- The template- Returns:
- The current instance of the builder for chaining
-
columnMapped
Creates aColumnMapItemPreparedStatementSetterto be used as yourItemPreparedStatementSetter.NOTE: The item type for this
ItemWritermust be castable toMap<String,Object>>.- Returns:
- The current instance of the builder for chaining
- See Also:
-
beanMapped
Creates aBeanPropertyItemSqlParameterSourceProviderto be used as yourItemSqlParameterSourceProvider.- Returns:
- The current instance of the builder for chaining
- See Also:
-
build
Validates configuration and builds theJdbcBatchItemWriter.- Returns:
- a
JdbcBatchItemWriter
-