今天想实现给指定表插入数据,出现了

### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''api_assets0' (id,name, level,type,file_id)
values
(3' at line 1
### The error may exist in file [E:\java\project\admin\devide\target\classes\mapper\ApiAssetsMapper.xml]
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: insert into ? (id,name, level,type,file_id) values (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?) , (?,?, ?,?,?)
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''api_assets0' (id,name, level,type,file_id)
values
(3' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''api_assets0' (id,name, level,type,file_id)
values

mapper里

int insert(@Param("list") List<ApiAssets> list,@Param("one") String one);

XML里

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.abc.devide.demo.mapper.ApiAssetsMapper">
……
<insert id="insert">
insert into #{one} (id,name, level,type,file_id)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.name}, #{item.level},#{item.type},#{item.fileId})
</foreach>
</insert> </mapper>

解决方法:

  使用 ${} 接受表名,#{}接受其他参数

将insert部分改为

<insert id="insert">
insert into ${one} (id,name, level,type,file_id)
values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.id},#{item.name}, #{item.level},#{item.type},#{item.fileId})
</foreach>
</insert>

就可以成功执行了

${} 同 #{} 的区别 查看

解决mybatis中#{}导致的The error may involve defaultParameterMap的问题的更多相关文章

  1. 解决mybatis中转义字符的问题

    xml格式中不允许出现类似“>”这样的字符,有如下两种解决方法 方法一:使用转义字符 SELECT * FROM test WHERE 1 = 1 AND start_date <= CU ...

  2. 解决mybatis中 数据库column 和 类的属性名property 不一致的两种方式

    解决方式way1:resultMap (1)studentMapper.xml <!-- 当数据库的字段名 和 类的属性名 不一致的时候的解决方式:2种 way1--> <selec ...

  3. [已解决] MyBatis 中bind用法

    JAVA: TC_ENTR_FLOW selectFlowForUpdate(String ENTR_ID); XML: <select id="selectFlowForUpdate ...

  4. ### The error may involve defaultParameterMap ### The error occurred while setting parameters

    Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Query was empty; bad SQL grammar [ ...

  5. “mybatis 中使用foreach 传

    为了帮助网友解决“mybatis 中使用foreach 传”相关的问题,中国学网通过互联网对“mybatis 中使用foreach 传”相关的解决方案进行了整理,用户详细问题包括:mybatismap ...

  6. 学习Spring Boot:(十二)Mybatis 中自定义枚举转换器

    前言 在 Spring Boot 中使用 Mybatis 中遇到了字段为枚举类型,数据库存储的是枚举的值,发现它不能自动装载. 解决 内置枚举转换器 MyBatis内置了两个枚举转换器分别是:org. ...

  7. 在mybatis中使用存储过程报错java.sql.SQLException: ORA-06550: 第 1 行, 第 7 列: PLS-00905: 对象 USER1.HELLO_TEST 无效 ORA-06550: 第 1 行, 第 7 列:

    hello_test是我的存储过程的名字,在mapper.xml文件中是这么写的 <select id="getPageByProcedure" statementType= ...

  8. 解决MWPhotoBrowser中的SDWebImage加载大图导致的内存警告问题

    下面两种现象,用同一种方法解决 1.解决MWPhotoBrowser中的SDWebImage加载大图导致的内存警告问题 2.突然有一天首页访问图片很慢,至少隔20多秒所有图片才会出来.(解析:app使 ...

  9. Android中解决图像解码导致的OOM问题

    Android中解决图像解码导致的OOM问题 原文链接:http://blog.csdn.net/zjl5211314/article/details/7042017

随机推荐

  1. Linux 笔记 - 第二十四章 配置 Tomcat

    一.前言 Tomcat 是 Apache 软件基金会(Apache Software Foundation)Jakarta 项目中的核心项目,由 Apache.Sun 和其他一些公司及个人共同开发.使 ...

  2. jQuery.form 上传文件

    今年大部分是都在完善产品,这几天遇到了一个问题,原来的flash组件不支持苹果浏览器,需要改.在网上搜了下,看到一个jQuery.form插件可以上传文件,并且兼容性很好,主要浏览器大部分都兼容,插件 ...

  3. Mvc中模拟模型

    如题,每次研究前台技术都要建数据库.连接,还遇到VS各种版本问题,太麻烦. 写这么一个东西,模仿后台Model,上课的时候研究代码层面的内容.甚好. 数据库类: class myDatabase { ...

  4. java 使用tess4j实现OCR的最简单样例

    网上很多教程没有介绍清楚tessdata的位置,以及怎么配置,并且对中文库的描述也存在问题,这里介绍一个最简单的样例. 1.使用maven,直接引入依赖,确保你的工程JDK是1.8以上 <dep ...

  5. django rest_framework vue 实现用户登录

    django rest_framework vue 实现用户登录 后端代码就不介绍了,可以参考  django rest_framework 实现用户登录认证 这里介绍一下前端代码,和前后端的联调过程 ...

  6. pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])

    1.pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.S ...

  7. Flask 中内置的 Session 应用

    目录 1.Flask 中 session 是需要 secret_key 的 2.session抛异常 3.session 用法: 4.验证session Flask中的Session非常的奇怪,他会将 ...

  8. [转]【会话技术】Session技术

    创建时间:6.29 & 6.30 一.Session技术 Session技术是将数据存储在服务器端的技术,会为每个客户端都创建一块内存空间  存储客户的数据,但客户端需要每次都携带一个标识ID ...

  9. 编写体面的UI测试

    --01-- PageObject简介   PageObject是编写UI测试时的一种模式.简而言之,你可以将所有知道页面细节的部分放入到这个对象上,对于编写测试的人来说,一个PageObject代表 ...

  10. HFS ~ Http File Server

    HFS ~ Http File Server官网:https://www.rejetto.com/hfs/ 官方下载地址:https://www.rejetto.com/hfs/hfs.exe