ITPub博客

首页 > 数据库 > > Mybatis查询报错

Mybatis查询报错

作者:wyvernw 时间:2019-10-16 10:53:45 0 删除 编辑

报错内容: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:

<insert id="insertUser" parameterType="com.xxx.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>

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

mybatis中不管什么查询,都必须返回resultType或者resultMap的值,否则就会报错的。resultType或者resultMap是orm框架的核心,必须有所映射,即数据层到Java类的映射关系。

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/835/viewspace-3146563/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-04-12

  • 博文量
    128
  • 访问量
    1296