ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gregg D Bolinger <gthou...@gmail.com>
Subject Re: Transactions/BatchStatements
Date Wed, 04 May 2005 15:46:17 GMT
I am curious as to iBatis batching also.  I have a question.  From
what you stated below, I am inferring that when you start a
transaction, all inserts/updates/deletes are batched and then sent on
commit?  Here is my problem.  I need to batch updates and inserts to
multiple tables.  So I am doing something like this.

daoManager.startTransaction
for loop {
  personDAO.insert
}
for loop{
  fooDAO.insert
}
daoManager.commit
finally
daoManager.endTransaction

So are all the inserts for personDAO and fooDAO batched at this point
automatically?

Gregg


On 5/3/05, Simon Brunner <lists@simonbrunner.com> wrote:
> List,
> 
> we just started a project from scratch and chose Spring/iBatis/Struts to
> build a mid-size J2EE web application. First I've to say that I'm very
> impressed on how fast you get productive by using iBatis. Everything went
> smooth until I wanted to do a batch insert. As we write JUnit testclasses
> for the entire app I used my iBatis DAOS without Spring's transaction
> demarcation (simply invoked the Dao by a test class). Under that
> environment iBatis executed my batch statements as single inserts until I
> read these lines in the mailing list archive:
> 
> > Clinton Begin
> > Wed, 01 Dec 2004 12:00:53 -0800
> 
> >> I'm currently using IBatis version 2.0.3. I'm not able to work upon with
> >> Batch. I'm
> >> doing the following :
> >> sqlMap.startBatch();
> 
> > Are you starting a the transaction too?  So...
> 
> > startTransaction()
> > startBatch()
> > insert...
> > update...
> > executeBatch()
> > commitTransaction()
> > endTransaction
> 
> Then I added transaction-support to my Spring Dao and it worked. Now I
> wonder why the execution of batch updates relys on the start and commit of
> a transaction?
> 
> Thanks & best regards
> 
> Simon
> 
>

Mime
View raw message