A query was run and no Result Maps were found for the Mapped Statement

简介: A query was run and no Result Maps were found for the Mapped Statement
Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement
'user.insertUser!selectKey'. It's likely that neither a Result Type nor a Result Map was specified.

这是使用MyBatis最常见的一种错误,从其描述来看是user.insertUser!selectKey这个Statement没有Result TypeResult Map

<insert id="insertUser" parameterType="com.luchao.mybatis.first.po.User">
  <selectKey keyProperty="id" order="AFTER" >
    select LAST_INSERT_ID()
  </selectKey>
  insert into user(username,birthday,sex,address) value (#{username},#{birthday},#{sex},#{address});
</insert>

这里是没有 resultType 所致的。

mybatis中不管什么查询,都必须返回resultType或者resultMap的值,否则就会报错的。

相关文章
|
3月前
|
SQL IDE Java
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
hibernate5 Cannot create TypedQuery for query with more than one return using requested result type
47 0
|
XML SQL 数据库
Error getting generated key or setting result to parameter object.必须执行该语句才能获得结果。
Error getting generated key or setting result to parameter object.必须执行该语句才能获得结果。
2622 47
|
3月前
|
druid Java
Error attempting to get column ‘createTime‘ from result set的异常
Error attempting to get column ‘createTime‘ from result set的异常
232 0
|
3月前
|
自然语言处理 数据库
Expected one result (or null) to be returned by selectOne(), but found: 2
Expected one result (or null) to be returned by selectOne(), but found: 2
66 0
|
SQL 关系型数据库 MySQL
MySQL - Expected one result (or null) to be returned by selectOne(), but found: 2
MySQL - Expected one result (or null) to be returned by selectOne(), but found: 2
558 0
|
数据库
Multiple Server Query Execution报The result set could not be merged..
在SQL Server中使用Multiple Server Query Execution这个功能做数据库维护或脚本发布时非常方便,昨天由于磁盘空间原因,删除清理了大量的软件和组件,结果导致SSMS客户端出了问题,重装过后,使用Multiple Server Query Execution时,出现了...
978 0