org.springframework.batch.item.database
Class IbatisBatchItemWriter<T>

java.lang.Object
  extended by org.springframework.batch.item.database.IbatisBatchItemWriter<T>
All Implemented Interfaces:
ItemWriter<T>, InitializingBean

public class IbatisBatchItemWriter<T>
extends Object
implements ItemWriter<T>, InitializingBean

ItemWriter that uses the batching features from SqlMapClientTemplate to execute a batch of statements for all items provided.
The user must provide an iBATIS statement id that points to the SQL statement defined in the iBATIS SqlMap configuration.
It is expected that write(List) is called inside a transaction.
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:
2.0
Author:
Thomas Risberg

Field Summary
protected static Log logger
           
 
Constructor Summary
IbatisBatchItemWriter()
           
 
Method Summary
 void afterPropertiesSet()
          Check mandatory properties - there must be an SqlMapClient 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 setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
          Public setter for SqlMapClient for injection purposes.
 void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate)
          Public setter for the SqlMapClientTemplate.
 void setStatementId(String statementId)
          Public setter for the statement id identifying the statement in the SqlMap configuration file.
 void write(List<? extends T> items)
          Process the supplied data element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Log logger
Constructor Detail

IbatisBatchItemWriter

public IbatisBatchItemWriter()
Method Detail

setAssertUpdates

public 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.

Parameters:
assertUpdates - the flag to set. Defaults to true;

setSqlMapClient

public void setSqlMapClient(com.ibatis.sqlmap.client.SqlMapClient sqlMapClient)
Public setter for SqlMapClient for injection purposes.

Parameters:
sqlMapClient - the SqlMapClient

setSqlMapClientTemplate

public void setSqlMapClientTemplate(SqlMapClientTemplate sqlMapClientTemplate)
Public setter for the SqlMapClientTemplate.

Parameters:
sqlMapClientTemplate - the SqlMapClientTemplate

setStatementId

public void setStatementId(String statementId)
Public setter for the statement id identifying the statement in the SqlMap configuration file.

Parameters:
statementId - the id for the statement

afterPropertiesSet

public void afterPropertiesSet()
Check mandatory properties - there must be an SqlMapClient and a statementId.

Specified by:
afterPropertiesSet in interface InitializingBean

write

public void write(List<? extends T> items)
Description copied from interface: ItemWriter
Process the supplied data element. Will not be called with any null items in normal operation.

Specified by:
write in interface ItemWriter<T>


Copyright © 2013 SpringSource. All Rights Reserved.