Bu sınıf JdbcBatchItemWriterBuilder tarafından da yaratılabilir
setItemSqlParameterSourceProvider metodu
Örnek
Şöyle yaparız
@Bean
public JdbcBatchItemWriter<Customer> customerItemWriter(DataSource dataSource) {
JdbcBatchItemWriter<Customer> writer = new JdbcBatchItemWriter<>();
writer.setItemSqlParameterSourceProvider(
new BeanPropertyItemSqlParameterSourceProvider<>());
writer.setSql("INSERT INTO customers (id, name, email) VALUES (:id, :name, :email)");
writer.setDataSource(dataSource);
return writer;
}
Açıklaması şöyle
The `JdbcBatchItemWriter` is configured to insert data into a database table called “customers”. It uses a `BeanPropertyItemSqlParameterSourceProvider` to map the `Customer` object to SQL parameters, and the SQL statement is defined as a string.
Hiç yorum yok:
Yorum Gönder