mybatis插入数据时报错:

Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: java.sql.SQLException: 不支持的特性
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)

原因:加了如下标红的设置(useGeneratedKeys="true"把新增加的主键赋值到自己定义的keyProperty(id)中)

<insert id="insert" parameterType="com.vimtech.bms.business.domain.monitor.finan.AssetsVisitReportWithBLOBs" useGeneratedKeys="true" keyProperty="serialid">

解决方法一:没什么用的话,删除标红的即可;

解决方法二:用selectKey先查下自增的主键ID值然后赋给相应的主键ID即可

oracle的写法(查序列的下一个值然后赋值):

<selectKey resultType="java.lang.Long" order="BEFORE" keyProperty="###">
  SELECT SEQ_ASSETS_VISIT_REPORT.nextval AS ### FROM dual
</selectKey>

SQLServer的写法

<selectKey resultType="java.lang.Integer" keyProperty="timelineConfigId">
  SELECT @@IDENTITY AS TIMELINE_CONFIG_ID
</selectKey>

Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: java.sql.SQLException: 不支持的特性的更多相关文章

  1. 出错:Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'cn.mgy.mapper.UserMapper.findById'.

    详细出错代码: org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.a ...

  2. SpringBoot报错:nested exception is org.apache.ibatis.executor.ExecutorException: No constructor found in com.tuyrk.test.User matching [java.lang.Long, java.lang.String, java.lang.String]

    错误提示: Caused by: org.apache.ibatis.executor.ExecutorException: No constructor found in com.tuyrk._16 ...

  3. Mybatis报错Cause: org.apache.ibatis.executor.ExecutorException: Executor was closed.

    SqlSession被关闭了,检查是否使用了被关闭的SqlSession.

  4. mybatis插入出现org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty 'xxx'异常的原因

    确定有setter方法,问题其实是xml文件中,insert的主键的列名写错了,如下,一开始写成ComId <insert id="insertCom" parameterT ...

  5. org.apache.ibatis.executor.ExecutorException: No constructor found in xxxClass matching [java.lang.String, java.lang.Long, java.lang.String, java.lang.String, java.sql.Timestamp]

    解决方案 为bean加上默认构造方法 public class User { private String username; private long id; private String sex; ...

  6. Mybatis出现错误org.apache.ibatis.executor.ExecutorException: No constructor found in

    错误显示没有发现构造器. 其实就是重写了构造器后,忘了补写一个默认的空参构造器了.此类的错误还经常出现在spring等这种大量使用反射的框架中.因为这些框架在调用反射的类后会默认调用默认的构造器 解决 ...

  7. uncategorized SQLException for SQL []; SQL state [99999]; error code [17004]; 无效的列类型: 1111; nested exception is java.sql.SQLException: 无效的列类型: 1111

    WHERE 的条件取值时添加上jdbcType=NUMBER这样的配置 参考[1]:https://blog.csdn.net/fyhjuyol/article/details/45483167

  8. Error getting nested result map values for 'company'. Cause: java.sql.SQLException: Invalid value for getInt() - 'NFHK188'

    我今天遇到一个我不解的问题,是mybatis多对一关系查询出问题了,但是我自己还是解决了,在网上也查过那个错误,可是找不到我想要的.不知道你们遇到过没有,我接下来分享给大家.希望我这个第一篇博客能帮助 ...

  9. mybatis查询异常-Error querying database. Cause: java.lang.ClassCastException: org.apache.ibatis.executor.ExecutionPlaceholder cannot be cast to java.util.List

    背景,mybatis查询的时候直接取的sqlsession,没有包装成SqlSessionTemplate,没有走spring提供的代理. 然后我写的获取sqlsession的代码没有考虑到并发的情况 ...

随机推荐

  1. TF-IDF与主题模型 - NLP学习(3-2)

    分词(Tokenization) - NLP学习(1) N-grams模型.停顿词(stopwords)和标准化处理 - NLP学习(2) 文本向量化及词袋模型 - NLP学习(3-1) 在上一篇博文 ...

  2. C++ 中神奇的头文件,懒人专用

    今天在做题的时候,偶然发现了一种神奇头文件.他的使用方法以及内容如下: #include <bits/stdc++.h> // C++ includes used for precompi ...

  3. lintcode-83-落单的数 II

    83-落单的数 II 给出3*n + 1 个的数字,除其中一个数字之外其他每个数字均出现三次,找到这个数字. 样例 给出 [1,1,2,3,3,3,2,2,4,1] ,返回 4 挑战 一次遍历,常数级 ...

  4. pta编程(1-8)

    知识点:本次编程运用到的格式 #include<stdio.h> int main(void) { printf(); return 0; } 过程:1-3.没什么问题,就是注意字符的输入 ...

  5. scrapy使用记录

    1 进入pip安装目录 python -m pip install --upgrade pip pip install Scrapy 2. 创建一个项目 scrapy startproject tes ...

  6. [Elasticsearch] 多字段搜索 (一) - 多个及单个查询字符串

    多字段搜索(Multifield Search) 本文翻译自官方指南的Multifield Search一章. 查询很少是只拥有一个match查询子句的查询.我们经常需要对一个或者多个字段使用相同或者 ...

  7. thinkphp3.2 常用单字母函数

    U函数:用来生成url U('地址表达式',['参数'],['伪静态后缀'],['显示域名'] 例如: U('Blog/read?id=1') // 生成Blog控制器的read操作 并且id为1的U ...

  8. [C/C++] extern关键字详解以及与static、const区别

    extern用法详解: 1. 声明外部实体 声明外部全局变量或对象,一般用于头文件中,表示在其它编译单元内定义的变量,链接时进行外部链接,如: extern int ivalue; 此时的extern ...

  9. Docker实战系列一:初识Docker for Windows

    windows下安装Docker官网教程Install Docker for Windows Docker配置官网教程Get started with Docker for Windows

  10. Jprofiler分析WebSphere(配置WebSphereagent代理)

    一.   Windows+WebSphere+Jprofiler9 我们自己的windows机器监控本地的WebSphere,应该为服务器配置监控代理,供Jprofiler连接使用,具体步骤如下: 1 ...