ibatis-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Question on Transactions and Batches
Date Fri, 16 Jun 2006 18:54:05 GMT
Here's a little more detail...

Without a transaction, the first statement after a batch is added to the
iBATIS Batch object.  HSQLDB appears to execute the statement when the
addBatch() statement is executed - this is why the tests don't fail.  But
all statements after the first one are executed as if they are not in a
batch (with implicit transactions).

Since there is no explicit transaction, then every statement is auto
committed by iBATIS.  So yes, all statements will be automatically committed
when they are executed - NOT when the executeBatch method runs.  The
executeBatch method basically does nothing in this case.

Jeff Butler



On 6/16/06, Huang, Richard X <Richard.X.Huang@questdiagnostics.com> wrote:
>
>  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:jeffgbutler@gmail.com]
> *Sent:* Friday, June 16, 2006 10:31 AM
> *To:* dev@ibatis.apache.org
> *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.
>
> ==============================================================================
>

Mime
View raw message