正文
Springboot+Mybatis批量导入多条数据
小程序:扫一扫查出行
【扫一扫了解最新限行尾号】
复制小程序
【扫一扫了解最新限行尾号】
复制小程序
在Mapper.xml最下面填写
<!-- 批量插入生成的兑换码 -->
<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 >