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: The statement must be executed before any results can be obtained.
; uncategorized SQLException for SQL []; SQL state [null]; error code [0]; The statement must be executed before any results can be obtained.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The statement must be executed before any results can be obtained.
触发器没问题,Mapper配置也没问题,两边单独运行也没问题。
结论:SQLserver触发器和Mybatis的Mapper有冲突。
在触发器中添加语句
SET NOCOUNT ON
解决!