多对多的关联关系,建立了中间表,现在我想批量更新中间表的信息,该怎么传值,我能不能把我需要更新的中间表的id用数组装起来,现在不知mapper.xml里面怎么拼那个sql
mybatis的xml里有一个foreach标签,然后用
insert into
表面(字段)
values
值,值
具体的记不太清了,你百度搜下mybatis的foreach遍历
mybatis的xml里有一个foreach标签,然后用
insert into
表面(字段)
values
值,值
具体的记不太清了,你百度搜下mybatis的foreach遍历
不是这个批量插入,插入那个我知道,我现在是批量更新有问题
<update id="batchUpdateGoodsTag" parameterType="java.util.List">
update dt_ec.goods_tag set goods_tag.goods_id=#{goodsId},goods_tag.tag_id=#{tagId}
where taggoods_id in
<foreach collection="list" item="item.taggoods_id" open="("
separator="," close=")">
#{item.taggoods_id}
</foreach>
</update>
2017-10-21 10:40:37.947 DEBUG |a|CloudXArchivesServantImpl.java:batchUpdateGoodsTag:1331|request: BatchUpdateGoodsTagReq[session=UserSession[
sessionKey=a,sessionAuth=b],goodsTagList=ArrayList{GoodsTag[taggoodsId=79,goodsId=22,tagId=11],GoodsTag[taggoodsId=80,goodsId=1,tagId=1]}]
2017-10-21 10:40:37.960 ERROR |a|CloudXArchivesServantImpl.java:batchUpdateGoodsTag:1348|MyBatisSystemException[detailMessage=<null>,cause=Bi
ndingException[detailMessage=Parameter 'goodsId' not found. Available parameters are [list],cause=org.apache.ibatis.binding.BindingException@4a
8efa23,stackTrace={},suppressedExceptions=Collections.UnmodifiableRandomAccessList{}],stackTrace={},suppressedExceptions=Collections.Unmodifiab
leRandomAccessList{}]
不知道我这个sql拼的那里有问题
多表连接,然后用limit限制更新哪几条记录