ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Question on Transactions and Batches
Date Fri, 16 Jun 2006 17:31:04 GMT
I've noticed something when doing some work on an improved executeBatch
method.  If you don't include your batch in an explicit transaction, nothing
will be executed.  For example, if I do this:

sqlMap.startBatch();
sqlMap.insert("someStatement", someObject);
 sqlMap.insert("someStatement", anotherObject);
sqlMap.executeBatch();

Nothing get executed.  The reason is that each insert method clears out the
session (and the associated batch) when it executes because it is assuming
an implicit transaction.  So when the executeBatch() method executes there
is no batch in the session.  If I do this:

sqlMap.startTransaction();
 sqlMap.startBatch();
sqlMap.insert("someStatement", someObject);
 sqlMap.insert("someStatement", anotherObject);
sqlMap.executeBatch();
sqlMap.commitTransaction();

Then everything is OK.

Question - is this the intended way this should work?  Or, is this an
unintended side effect of the relatively new implicit transaction support?

If this is intended, then we need to change the documentation because it is
wrong.  If it's unintended, then we need to fix the code.

Comments?

Jeff Butler

Mime
View raw message