Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result t

Posted xh_Blog

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result t相关的知识,希望对你有一定的参考价值。

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 t的主要内容,如果未能解决你的问题,请参考以下文章

Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no gette

Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter

Cause: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result t

出错:Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were foun

Mybatis报错 Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: Error

mybatis查询异常-Error querying database. Cause: java.lang.ClassCastException: org.apache.ibatis.executo