【无标题】

 mybatis 批量插入数据,xml文件到底如何写呀 ?这里备注一下

1. 批量插入数据:batchInsert

mapper 代码: 

package com.xxxx.mapper;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface XXXXRepoMapper extends Mapper {

    void batchInsert(@Param("list") List list);

}

mapper xml




    
        
        
        
        
        
        
        
        
        
        
    


    
        t_xxx_repo
    

    
        id,code,name,parent_code,type,active_flag,creator,modifier,create_time,modify_time
    

    
        insert into 
        () values
        
            (null,#{item.code,jdbcType=VARCHAR},#{item.name,jdbcType=VARCHAR},#{item.parentCode,jdbcType=VARCHAR},#{item.type,jdbcType=TINYINT},1,
            #{item.creator,jdbcType=BIGINT},#{item.modifier,jdbcType=BIGINT},now(),now())
        
    



2. 批量更新数据:batchUpdate

你可能感兴趣的:(mybatis)