ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaqiQi...@aol.com
Subject how to use batch transaction if iBATIS DAO is used
Date Sun, 19 Mar 2006 20:23:37 GMT
all,

If we use iBATIS (sqlMap) only, I can write following code for batch 
transaction and make it atomic:

try {
            //do batch insert here
            sqlMap.startTransaction();
            sqlMap.startBatch ();
            for (int i=0, n=list.size(); i < n; i++) {
                sqlMap.insert ("insertSession", list.get(i));
            }
            sqlMap.executeBatch();
            sqlMap.commitTransaction();
       }catch (Exception e){
            logger.error( e);
            throw new DAOException( e);
        } finally {
            try {
                sqlMap.endTransaction();
            } catch (SQLException ex) {
                logger.error( ex);
                throw new SaveException( ex);
            }
        }

If we use iBATIS DAO, do i need to push batch transaction to service layer? 
At service layer, we can have daoManager to make all insert transactions 
atomic. Any suggestions?

Appreciate your help.

Tony

Mime
View raw message