ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hycel Taylor <hyc...@gmail.com>
Subject Re: How do I do batch processing with IBatis DAO
Date Thu, 11 Aug 2005 19:01:17 GMT
I want to make sure I'm understanding how to use iBatis batching correctly.

I understand now that SqlMapDaoTemplate, contains the method,
startBatch() and execute batch.  My Dao will extend SqlMapBaseDao
which extends SqlMapDaoTemplate.

So, since my Dao's are sharing the same daoManager, if I startBatch()
on each dao, do some work, and then executeBatch() on each dao, the
set of Dao's will be considered to be apart of the same batch?

Example: 

try {
    daoManager.startTransaction();

    SqlMapSchoolDao schoolDao = new SqlMapSchoolDao(daoManager);
    SqlMapMajorDao majorDao = new SqlMapMajorDao(daoManager);
    SqlMapCourseDao courseDao = new SqlMapCourseDao(daoManager);
    
    schoolDao.startBatch();
    majorDao.startBatch();
    courseDao.startBatch();
    
    // Do some iterative tasks.
    
    schoolDao.executeBatch();
    majorDao.executeBatch();
    courseDao.executeBatch();

  } catch (Exception e) {
    throw new ServiceException(e.getMessage());
  } finally {
    daoManager.endTransaction();
  }

Mime
View raw message