Class JdbcBatchItemWriterBuilder<T>
- java.lang.Object
- org.springframework.batch.item.database.builder.JdbcBatchItemWriterBuilder<T>
public class JdbcBatchItemWriterBuilder<T> extends java.lang.ObjectA builder implementation for theJdbcBatchItemWriter.- Since:
- 4.0
- Author:
- Michael Minella
- See Also:
JdbcBatchItemWriter
Constructor Summary
Constructors Constructor Description JdbcBatchItemWriterBuilder()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 aBeanPropertyItemSqlParameterSourceProviderto be used as yourItemSqlParameterSourceProvider.JdbcBatchItemWriter<T>build()Validates configuration and builds theJdbcBatchItemWriter.JdbcBatchItemWriterBuilder<T>columnMapped()Creates aColumnMapItemPreparedStatementSetterto be used as yourItemPreparedStatementSetter.JdbcBatchItemWriterBuilder<T>dataSource(javax.sql.DataSource dataSource)Configure theDataSourceto be used.JdbcBatchItemWriterBuilder<T>itemPreparedStatementSetter(ItemPreparedStatementSetter<T> itemPreparedStatementSetter)Configures aItemPreparedStatementSetterfor use by the writer.JdbcBatchItemWriterBuilder<T>itemSqlParameterSourceProvider(ItemSqlParameterSourceProvider<T> itemSqlParameterSourceProvider)Configures aItemSqlParameterSourceProviderfor use by the writer.JdbcBatchItemWriterBuilder<T>namedParametersJdbcTemplate(org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations namedParameterJdbcOperations)TheNamedParameterJdbcOperationsinstance to use.JdbcBatchItemWriterBuilder<T>sql(java.lang.String sql)Set the SQL statement to be used for each item's updates.
Method Detail
dataSource
public JdbcBatchItemWriterBuilder<T> dataSource(javax.sql.DataSource dataSource)
Configure theDataSourceto 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 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:
JdbcBatchItemWriter.setItemPreparedStatementSetter(ItemPreparedStatementSetter)
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:
JdbcBatchItemWriter.setItemSqlParameterSourceProvider(ItemSqlParameterSourceProvider)
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
public JdbcBatchItemWriterBuilder<T> columnMapped()
Creates aColumnMapItemPreparedStatementSetterto be used as yourItemPreparedStatementSetter. NOTE: The item type for thisItemWritermust be castable toMap<String,Object>>.- Returns:
- The current instance of the builder for chaining
- See Also:
ColumnMapItemPreparedStatementSetter
beanMapped
public JdbcBatchItemWriterBuilder<T> beanMapped()
Creates aBeanPropertyItemSqlParameterSourceProviderto be used as yourItemSqlParameterSourceProvider.- Returns:
- The current instance of the builder for chaining
- See Also:
BeanPropertyItemSqlParameterSourceProvider
build
public JdbcBatchItemWriter<T> build()
Validates configuration and builds theJdbcBatchItemWriter.- Returns:
- a
JdbcBatchItemWriter