ibatis批量平添

ibatis批量添加/*** 批量提交EtlTask* @param taskList*/public void insert(final ListEtlTask taskLis

ibatis批量添加
/**
     * 批量提交EtlTask
     * @param taskList
     */
    public void insert(final List<EtlTask> taskList) {

        try {
            this.getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
                public Object doInSqlMapClient(SqlMapExecutor executor)
                                                                       throws SQLException {
                    executor.startBatch();
                    int batch = 0;
                    for (EtlTask task : taskList) {
                           executor.insert("SERV_ETL_TASK.insertFromProgram", task);
                        batch++;
                        //每500条批量提交一次。
                        if (batch == 500) {
                            executor.executeBatch();
                            batch = 0;
                        }
                    }
                    executor.executeBatch();
                    return null;
                }
            });

        } catch (DataAccessException ex) {
            logger.error("每天初始化任务中,添加新 ETL Task 记录出错", ex);
            throw ex;
        }
    }