Class MyBatisBatchItemWriter<T>

java.lang.Object
org.mybatis.spring.batch.MyBatisBatchItemWriter<T>
All Implemented Interfaces:
org.springframework.batch.item.ItemWriter<T>, org.springframework.beans.factory.InitializingBean

public class MyBatisBatchItemWriter<T> extends Object implements org.springframework.batch.item.ItemWriter<T>, org.springframework.beans.factory.InitializingBean
ItemWriter that uses the batching features from SqlSessionTemplate to execute a batch of statements for all items provided.

Provided to facilitate the migration from Spring-Batch iBATIS 2 writers to MyBatis 3.

The user must provide a MyBatis statement id that points to the SQL statement defined in the MyBatis.

It is expected that write(Chunk) is called inside a transaction. If it is not each statement call will be autocommitted and flushStatements will return no results.

The writer is thread safe after its properties are set (normal singleton behavior), so it can be used to write in multiple concurrent transactions.

Since:
1.1.0
Author:
Eduardo Macarron