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
- See Also:
-
Constructor Summary
-
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 aBeanPropertyItemSqlParameterSourceProvider
to be used as yourItemSqlParameterSourceProvider
.build()
Validates configuration and builds theJdbcBatchItemWriter
.Creates aColumnMapItemPreparedStatementSetter
to be used as yourItemPreparedStatementSetter
.dataSource
(DataSource dataSource) Configure theDataSource
to be used.itemPreparedStatementSetter
(ItemPreparedStatementSetter<T> itemPreparedStatementSetter) Configures aItemPreparedStatementSetter
for use by the writer.itemSqlParameterSourceProvider
(ItemSqlParameterSourceProvider<T> itemSqlParameterSourceProvider) Configures aItemSqlParameterSourceProvider
for use by the writer.namedParametersJdbcTemplate
(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations namedParameterJdbcOperations) TheNamedParameterJdbcOperations
instance to use.Set the SQL statement to be used for each item's updates.
-
Constructor Details
-
JdbcBatchItemWriterBuilder
public JdbcBatchItemWriterBuilder()
-
-
Method Details
-
dataSource
Configure theDataSource
to 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 aItemPreparedStatementSetter
for 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 aItemSqlParameterSourceProvider
for 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) TheNamedParameterJdbcOperations
instance to use. If one isn't provided, aDataSource
is required.- Parameters:
namedParameterJdbcOperations
- The template- Returns:
- The current instance of the builder for chaining
-
columnMapped
Creates aColumnMapItemPreparedStatementSetter
to be used as yourItemPreparedStatementSetter
. NOTE: The item type for thisItemWriter
must be castable toMap<String,Object>>
.- Returns:
- The current instance of the builder for chaining
- See Also:
-
beanMapped
Creates aBeanPropertyItemSqlParameterSourceProvider
to be used as yourItemSqlParameterSourceProvider
.- Returns:
- The current instance of the builder for chaining
- See Also:
-
build
Validates configuration and builds theJdbcBatchItemWriter
.- Returns:
- a
JdbcBatchItemWriter
-