在insert中添加俩属性,原来的list中的id,就会被赋值上,useGeneratedKeys="true" keyProperty="id"
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id"> INSERT INTO b_rfid_warn ( antenna_name, unit_code, remark, goods_id, batch, warn_reason, update_user_id, create_time, update_time, is_used, is_del, lable_code ) VALUES <foreach collection="list" item="item" separator=","> ( #{item.antennaName,jdbcType=VARCHAR}, #{item.unitCode,jdbcType=VARCHAR}, #{item.remark,jdbcType=VARCHAR}, #{item.goodsId,jdbcType=INTEGER}, #{item.batch,jdbcType=VARCHAR}, #{item.warnReason,jdbcType=VARCHAR}, #{item.updateUserId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.isUsed,jdbcType=INTEGER}, #{item.isDel,jdbcType=INTEGER}, #{item.lableCode,jdbcType=VARCHAR} ) </foreach> </insert>