码迷,mamicode.com
首页 > 移动开发 > 详细

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.

时间:2016-04-27 00:22:49      阅读:703      评论:0      收藏:0      [点我收藏+]

标签:

使用mybatis时出现异常问题:

有如下的错误

1 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 Type或Result Map。下面是我的配置文件的statement:

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

可以看出主要是<selectKey>没有resultType所致的。

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

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.

标签:

原文地址:http://www.cnblogs.com/lcngu/p/5437079.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!