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.write(List)
is called inside a transaction. If it is not
each statement call will be autocommitted and flushStatements will return no results.Constructor and Description |
---|
MyBatisBatchItemWriter() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Check mandatory properties - there must be an SqlSession and a statementId.
|
void |
setAssertUpdates(boolean assertUpdates)
Public setter for the flag that determines whether an assertion is made
that all items cause at least one row to be updated.
|
void |
setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
Public setter for
SqlSessionFactory for injection purposes. |
void |
setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
Public setter for the
SqlSessionTemplate . |
void |
setStatementId(String statementId)
Public setter for the statement id identifying the statement in the SqlMap
configuration file.
|
void |
write(List<? extends T> items) |
public void setAssertUpdates(boolean assertUpdates)
assertUpdates
- the flag to set. Defaults to true;public void setSqlSessionFactory(org.apache.ibatis.session.SqlSessionFactory sqlSessionFactory)
SqlSessionFactory
for injection purposes.SqlSessionFactory
- sqlSessionFactorypublic void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate)
SqlSessionTemplate
.SqlSessionTemplate
- the SqlSessionTemplatepublic void setStatementId(String statementId)
statementId
- the id for the statementpublic void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Copyright © 2010–2016 MyBatis.org. All rights reserved.