大家都知道,批量插入比一条一条插入要快,而且更节省资源,当然是在插入量不是很大的情况下,数据量大的话可以考虑批次插入。今天在做批量导入时碰到了一个问题:
Parameter ‘__frch_item_0’ not found. Available parameters are [map]
检查sql发现是字段名错了……
<insert id="batchInsert" parameterType="java.util.Map">
insert into bss_user_group_map
(cust_id, user_group_id, description,state, is_sync, create_date)
values
<foreach collection="map" item="item" index="index" separator="," >
(#{item.custI_d,jdbcType=VARCHAR}, #{item.userGroupId,jdbcType=BIGINT},
#{item.description,jdbcType=VARCHAR},'USABLE','NO',now())
</foreach>
</insert>
mapper接口:
int batchInsert(@Param("map") Map<String, UserGroupMap> userGroupMapBatch);
这里的custI_d应该是custId