Batch inserts/updates/deletes and BatchResults

329 views
Skip to first unread message

Matt Passell

unread,
Apr 11, 2012, 4:24:54 PM4/11/12
to mybati...@googlegroups.com
Hi All,

I've read through the user guide, past discussions in the group, and the MyBatis source, and I think I understand how I'd use a BatchExecutor to execute a batch and get back BatchResults for the executed statements, but I wanted to confirm that I'm on the right track.  Does code like the following (ignoring error handling for the moment) look reasonable?

    SqlSession session = ssFactory.openSession(ExecutorType.BATCH);
    GroupMapper mapper = session.getMapper(GroupMapper.class);
    
    for (Group group : groups) {
      mapper.addGroup(group);
    }
    
    List<BatchResult> results = session.flushStatements();
    session.commit();
    session.close();

Thanks,
Matt

Eduardo

unread,
Apr 12, 2012, 2:20:59 AM4/12/12
to mybatis-user
100% Matt. That is the right way to get the results.

KEN

unread,
Apr 12, 2012, 2:58:41 AM4/12/12
to mybatis-user
I have test, the test report show that: Comparing with ibatis,
mybatis's batch insert operation cost double time. It is close to
hibernate performance.

Eduardo Macarron

unread,
Apr 12, 2012, 3:27:45 AM4/12/12
to mybati...@googlegroups.com
Hi, Matt is referring to Spring-Batch, not to MyBatis-Batch.

This information is valued. Have you done a profiling? do you have any
idea of where the time is lost?

If you don't mind, please open a new thread to follow this conversation.

KEN

unread,
Apr 12, 2012, 4:02:49 AM4/12/12
to mybatis-user
Sorry, I am discussing in another thread, I attach the code and test
data, any advice is welcome.

topic: Mybatis is very much slower than Ibatis or Jdbc
url: http://groups.google.com/group/mybatis-user/browse_thread/thread/58ce58e1d708cac6

Eduardo Macarron

unread,
Apr 12, 2012, 11:57:43 AM4/12/12
to mybati...@googlegroups.com
El día 12 de abril de 2012 09:27, Eduardo Macarron
<eduardo....@gmail.com> escribió:

> Hi, Matt is referring to Spring-Batch, not to MyBatis-Batch.

Sorry for the mess. It is Prashant who asked about Spring Batch, not Matt :)

Matt Passell

unread,
Apr 12, 2012, 11:59:42 AM4/12/12
to mybati...@googlegroups.com
Hi Eduardo,

Thanks!  It appears to be working fine. :)

Thanks,
Matt

Matt Passell

unread,
Apr 12, 2012, 12:00:54 PM4/12/12
to mybati...@googlegroups.com
Thanks for clarifying that.  I was about to send an email saying, "Hmm. I thought I was talking about MyBatis-Batch..." ;)

--Matt
Reply all
Reply to author
Forward
0 new messages