Mybatis 批量插入

// 将用户集合放入map中
Map<String, List<Map<String, Object>>> usersListMap = newHashMap<String,List<Map<String, Object>>>();
usersListMap.put("usersList", objList);


<insert id="GoodsServiceImpl/batchGoodsInfo" parameterType="com.eightspace.baccy.db.entity.GoodsInfoEntity">
		INSERT INTO goods_info(
		        goodsid,
	            goodsbarcode,
	            goodsname, 
	            goodstype, 
	            goodsunit, 
	            price, 
	            tradeprice)
	    VALUES 
	    <foreach collection="goodsList" item="item" index="index"
             separator=",">
             (#{item.goodsId},#{item.goodsBarcode},#{item.goodsName},#{item.goodsType},#{item.goodsUnit},#{item.price},#{item.tradePrice})
        </foreach>
	</insert>

你可能感兴趣的:(mybatis)