【发布时间】:2020-01-07 06:07:21
【问题描述】:
<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...”附近使用的正确语法”
【问题讨论】:
标签: mybatis