ibatis批处理 实例

ibatis 批量处理,速度很快,适合批量数据导入操作使用。

/**
     * 添加角色菜单关系
     * 
     * @author : 路人甲
     * @create_date :2013-3-29 上午09:59:07
     * @param list
     */
    public void insertRoleMenuList(final List<RoleMenuRelationDTO> list) throws PafaDAOException
    {
            getSqlMapClientTemplate().execute(new SqlMapClientCallback()
            {
                public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException
                {
                    executor.startBatch();
                    for (RoleMenuRelationDTO dto : list)
                    {
                        executor.insert(RoleMenuConstant.CREATE_ROLEMENURELATION, dto);
                    }
                    return executor.executeBatch();
                }
            }).toString();
    }

 

posted on 2013-03-29 10:48  陈惟鲜的博客  阅读(187)  评论(0编辑  收藏  举报

导航