标签:foreach error update 属性 als for multi test generate
1,批量插入配置
<insert id="novel.insertBatch" parameterType="java.util.List" useGeneratedKeys="false"> INSERT INTO t_novel ( `name` ) values <foreach collection="list" item="item" index="index" separator="," > ( #{item.name}, ) </foreach> </insert>
2,批量更新配置
<update id="novel.updateBatch" parameterType="java.util.List"> <foreach collection="list" item="item" index="index" separator=";"> UPDATE t_novel set updateTime=NOW() <if test="item.name != null"> ,`name` = #{item.name} </if> WHERE id = #{item.id} </foreach> </update>
3,重要,重要,重要
链接属性里面追加
allowMultiQueries=true
否则抛出com.mysql.jdbc.exceptions.MySQLSyntaxErrorException异常
mybatis批量插入,批量更新 com.mysql.jdbc.exceptions.MySQLSyntaxErrorException
标签:foreach error update 属性 als for multi test generate
原文地址:http://www.cnblogs.com/lckblog/p/7845257.html