could add value just the same as BatchSqlUpdateItemWriter does.
Code:
public class BatchIbatisUpdateItemWriter<T> implements ItemWriter<T>, InitializingBean {
...
public void write(final List<? extends T> items) throws Exception {
if (!items.isEmpty()) {
int[] values = (int[]) sqlMapClientTemplate.execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.startBatch();
for (T item : items) {
executor.insert(queryId, item);
}
List<BatchResult> detailed;
try {
detailed = executor.executeBatchDetailed();
} catch (BatchException e) {
throw new SQLException(e.getMessage() + " statement id:"+e.getFailingStatementId() + ", sql:"+e.getFailingSqlStatement() + ", batch exception:"+e.getBatchUpdateException());
}
return detailed.get(0).getUpdateCounts();
}
});
if (assertUpdates) {
for (int i = 0; i < values.length; i++) {
int value = values[i];
if (value == 0) {
throw new EmptyResultDataAccessException("Item " + i + " of " + values.length
+ " did not update any rows: [" + items.get(i) + "]", 1);
}
}
}
}
}
...
}