The main questions to me, when you excute the batch, it will auto commit after you run the batch, or until you specificlly commit all the changes.
 
Richard
-----Original Message-----
From: Jeff Butler [mailto:[EMAIL PROTECTED]
Sent: Friday, June 16, 2006 10:31 AM
To: [email protected]
Subject: Question on Transactions and Batches

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
 

==============================================================================
The contents of this message, together with any attachments, are intended only for the use of the person(s) to which they are addressed and may contain confidential and/or privileged information. Further, any medical information herein is confidential and protected by law. It is unlawful for unauthorized persons to use, review, copy, disclose, or disseminate confidential medical information. If you are not the intended recipient, immediately advise the sender and delete this message and any attachments. Any distribution, or copying of this message, or any attachment, is prohibited.
==============================================================================

Reply via email to