Error getting generated key or setting result to parameter object.必须执行该语句才能获得结果。

本文涉及的产品
云数据库 RDS SQL Server,独享型 2核4GB
简介: Error getting generated key or setting result to parameter object.必须执行该语句才能获得结果。

错误详情:


org.springframework.jdbc.UncategorizedSQLException: Error getting generated key or setting result to parameter object. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: 必须执行该语句才能获得结果。

; uncategorized SQLException; SQL state [null]; error code [0]; 必须执行该语句才能获得结果。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: 必须执行该语句才能获得结果。


问题出现在一个插入语句中 ,之前做的项目数据库中的主键是自动递增的,新项目用的erp的数据库,xml文档都是复制粘贴的,结果一插入GG了,看一下插入语句:


<insert id="insert" useGeneratedKeys="true" keyProperty="id"
  parameterType="com.xxx.xxx.xxx.xdo.T_OrganizationDO">
  insert into t_Organization (
  <include refid="sqlKey" />
  ) values (
  <include refid="sqlValue" />
  )
</insert>

问题出现在了 :useGeneratedKeys=“true”

这个关键字的意思是插入本条记录并将自动递增的id反写到传入的对象参数中,erp中的表id并没有设置自动递增,所以这个地方自然报错,直接干掉就可以咯!


相关实践学习
使用SQL语句管理索引
本次实验主要介绍如何在RDS-SQLServer数据库中,使用SQL语句管理索引。
SQL Server on Linux入门教程
SQL Server数据库一直只提供Windows下的版本。2016年微软宣布推出可运行在Linux系统下的SQL Server数据库,该版本目前还是早期预览版本。本课程主要介绍SQLServer On Linux的基本知识。 相关的阿里云产品:云数据库RDS&nbsp;SQL Server版 RDS SQL Server不仅拥有高可用架构和任意时间点的数据恢复功能,强力支撑各种企业应用,同时也包含了微软的License费用,减少额外支出。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/sqlserver
相关文章
|
6月前
|
XML 关系型数据库 MySQL
【MySQL异常】ExecutorException: Error getting generated key or setting result to parameter object
【MySQL异常】ExecutorException: Error getting generated key or setting result to parameter object
126 0
|
5月前
|
关系型数据库 MySQL
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
mysql: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such
|
6月前
|
人工智能 自然语言处理 JavaScript
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in created hook: “TypeError: Object(...) is not a func
vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in created hook: “TypeError: Object(...) is not a func
48 0
error : Class declarations lacks Q_OBJECT macro
error : Class declarations lacks Q_OBJECT macro
|
9月前
error while loading shared libraries: libXXX.so.X: cannot open shared object file: No such file
error while loading shared libraries: libXXX.so.X: cannot open shared object file: No such file
197 0
|
JavaScript
js:Object对象按照key的升序排序
js:Object对象按照key的升序排序
192 0
This error might indicate a memory leak if setState() is being called because another object is reta
This error might indicate a memory leak if setState() is being called because another object is reta
exception(359): error C2220: 警告被视为错误 - 没有生成“object”文件
exception(359): error C2220: 警告被视为错误 - 没有生成“object”文件
83 0
exception(359): error C2220: 警告被视为错误 - 没有生成“object”文件
error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or
error while loading shared libraries: xxx.so.0:cannot open shared object file: No such file or
87 0
|
C++
编译OpenJDK12:methodMatcher.cpp error C2220 警告被视为错误 - 没有生成“object”文件
编译OpenJDK12:methodMatcher.cpp error C2220 警告被视为错误 - 没有生成“object”文件
115 0