<insert id="insertSelectiveBatch" parameterType="cn.indweb.blogcore.repository.model.Article">
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Thu Aug 22 10:38:37 CST 2019.
-->
<foreach item="item" collection="list" open="" close="" separator=";">
insert into tbl_article
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.id != null">
id,
</if>
<if test="item.title != null">
title,
</if>
<if test="item.author != null">
author,
</if>
<if test="item.content != null">
content,
</if>
<if test="item.createdTime != null">
created_time,
</if>
<if test="item.deletedTime != null">
deleted_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="item.id != null">
#{item.id,jdbcType=VARCHAR},
</if>
<if test="item.title != null">
#{item.title,jdbcType=VARCHAR},
</if>
<if test="item.author != null">
#{item.author,jdbcType=VARCHAR},
</if>
<if test="item.content != null">
#{item.content,jdbcType=VARCHAR},
</if>
<if test="item.createdTime != null">
#{item.createdTime,jdbcType=TIMESTAMP},
</if>
<if test="item.deletedTime != null">
#{item.deletedTime,jdbcType=TIMESTAMP},
</if>
</trim>
</foreach>
这是我尝试的代码,但是没有用。错误消息为“ java.sql.SQLSyntaxErrorException:您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以获取正确的语法以在“插入到tbl_article ...附近”中使用。”
答案 0 :(得分:-1)
为您的语句提供了Collection类型的参数。您根本不需要parameterType
。请尝试将其删除,然后再次尝试运行。