1. mybatis批量插入数据

 通过list

   <insert id="saveByList" useGeneratedKeys="true" parameterType="java.util.List"> 

     insert into T_App_Default_User(UserID,AppType,CreateTime)

    values  

    <foreach collection="list" item="item" index="index" separator="," >  

        (#{item.userId},#{item.appType},now())  

    </foreach> 

    </insert>

    

对应的Mapper文件

public interface AppDefaultUserMapper {

    void saveByList(List<Map<String, Long>> list);

}

搞定~~~

 

你可能感兴趣的:(mybatis)