Mybatis批量添加对象List

1.对应的xml文件:

<!--批量添加-->
<insert id="insertStandardItemInfo" parameterType="hashmap">
insert into t_standard_item(standard_id,item_id)
values
<foreach collection="itemIdList" index="index" item="item" separator="," >
(#{standardId,jdbcType=INTEGER}, #{item,jdbcType=INTEGER})
</foreach>
</insert>

2.对应的mapper文件:
int insertStandardItemInfo(Map<String,Object> map);

3.对应的service文件:
Map<String, Object> map = new HashMap<>();
map.put("standardId", standardId);
map.put("itemIdList", itemIdList);
standardItemMapper.insertStandardItemInfo(map);
 
 
posted @ 2016-09-23 10:11  esther-qing  阅读(12217)  评论(0编辑  收藏  举报