首先 這編博客經本人試用過,與理想效果一致
.MyBatis配置
這是mysql的配置,注意需要加上&allowMultiQueries=true配置
jdbc_url=jdbc:mysql://localhost:3306/go?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
'&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true' 是重點!之前就是因為這個一直沒有成功。。。。
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update channels
<set>
state=${item.state}
</set>
where id = ${item.id}
</foreach>
</update>
oracle和mysql的配置不一樣
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close="end;" separator=";">
update channels
<set>
state=${item.state}
</set>
where id = ${item.id}
</foreach>
</update>
Mysql的配置在實際運用中成功了,Oracle的沒有試過