今天要做批量更新的業(yè)務刽酱,采用mybaits的foreach動態(tài)語句卵洗,遇到一些問題做下記錄簿废。
<update id="" parameterType="">
<foreach collection="list" item="item" index="index">
update tb_question_template_seleteitem_detail set selectedName=#{item.selectedName}
where 1=1 and selectedId =#{item.selectedId };
</foreach>
</update>
這種情況一半會報錯夸赫,解決方式:在數(shù)據(jù)庫配置上添加 &allowMultiQueries=true
例如:jdbc:mysql://192.168.1.109:3306/healthmanage?characterEncoding=utf-8&allowMultiQueries=true