Ibatis startBatch() only works with SqlMapClient's own start and commit transactions, not with Sprin
- by Brian
Hi,
I'm finding that even though I have code wrapped by Spring transactions, and it commits/rolls back when I would expect, in order to make use of JDBC batching when using Ibatis and Spring I need to use explicit SqlMapClient transaction methods.
I.e. this does batching as I'd expect:
dao.getSqlMapClient().startTransaction();
dao.getSqlMapClient().startBatch();
int i = 0;
for (MyObject obj : allObjects)
{
dao.storeChange(obj);
i++;
if (i % DB_BATCH_SIZE == 0)
{
dao.getSqlMapClient().executeBatch();
dao.getSqlMapClient().startBatch();
}
}
dao.getSqlMapClient().executeBatch();
dao.getSqlMapClient().commitTransaction();
but if I don't have the opening and closing transaction statements, and rely on Spring to manage things (which is what I want to do!), batching just doesn't happen.
Given that Spring does otherwise seem to be handling its side of the bargain regarding transaction management, can anyone advise on any known issues here?
(Database is MySQL; I'm aware of the issues regarding its JDBC pseudo-batch approach with INSERT statement rewriting, that's definitely not an issue here)