简体   繁体   中英

Spring batch Itemwriter using Storedprocedure

我们可以在Spring批处理Itemwriter中使用Stored过程来编写数据或者Tasklet是唯一的方法吗?

I think you are looking something like this Invoking Stored Procedure using Spring JdbcBatchItemWriter

The answer is yes, implementing it is straightforward given the code below:

    JdbcBatchItemWriter<Person> writer = new JdbcBatchItemWriter<Person>();
    writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<Person>());
    writer.setSql("CALL SP(:firstName, :lastName)");
    writer.setDataSource(dataSource);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM