mybatis批量insert的mapper xml写法

来源:互联网 发布:虚拟q币充值软件 编辑:程序博客网 时间:2024/04/19 22:38
<!-- 批量插入生成的兑换码 -->
     <insert id ="insertCodeBatch" parameterType="java.util.List" >
            <selectKey resultType ="java.lang.Integer" keyProperty= "id"
                 order= "AFTER">
                SELECT LAST_INSERT_ID()
            </selectKey >
           insert into redeem_code
           (bach_id, code, type, facevalue,create_user,create_time)
           values
            <foreach collection ="list" item="reddemCode" index= "index" separator =",">
                (
                #{reddemCode.batchId}, #{reddemCode.code},
                #{reddemCode.type},
                #{reddemCode.facevalue},
                #{reddemCode.createUser}, #{reddemCode.createTime}
                )
            </foreach >
     </insert >
0 0