Mybatis报错—— A query was run and no Result Maps were found for the Mapped Statement
来源:互联网 发布:车牌号查询车主软件 编辑:程序博客网 时间:2024/05/22 09:48
Mybatis报错—— A query was run and no Result Maps were found for the Mapped Statement 。。。 It’s likely that neither a Result Type nor a Result Map was specified.
报错如下
org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.mapper.EmployeeMapper.getEmpByIdAndLastname'. It's likely that neither a Result Type nor a Result Map was specified.### The error may exist in com/mapper/EmployeeMapper.xml### The error may involve com.mapper.EmployeeMapper.getEmpByIdAndLastname### The error occurred while handling results### SQL: select * from tbl_employee where id = ? and last_name=?### Cause: org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'com.mapper.EmployeeMapper.getEmpByIdAndLastname'. It's likely that neither a Result Type nor a Result Map was specified. at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ... 29 more
异常分析:
关键在第一段提示: It’s likely that neither a Result Type nor a Result Map was specified.意思是无法确定返回值类型。
如下代码:
<select id="getEmpById" > select * from tbl_employee where id = #{id}</select>
在写select查询标签是,没加resultType属性。
异常解决,代码如下:
<select id="getEmpById" resultType="com.bean.Employee" > select * from tbl_employee where id = #{id}</select>
小结:
在写select查询标签进行查询时,必须写resultType属性,不然mybatis无法确定返回值类型,就会报错。
补充:
1.进行查询时,resultType(返回值类型)属性不能省略。
2.进行增删改时,parameterType(参数类型)属性可以省略,且它们没有resultType属性,返回值可以直接在Mapper接口上定义。
mybatis允许增删改查直接定义以下类型返回值(Mapper接口中定义)
Integer(返回SQL语句影响的行数)、
Long(同上)
Boolean(返回SQL语句是否执行成功)
<!-- parameterType:参数类型,可以省略 --><insert id="addEmp" parameterType="com.bean.Employee"> INSERT INTO tbl_employee VALUES (#{lastName}, #{gender},#{email}); </insert>
阅读全文
0 0
- Mybatis报错—— A query was run and no Result Maps were found for the Mapped Statement
- mybatis报错:A query was run and no Result Maps were found for the Mapped Statement
- mybatis报错: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
- 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
- A query was run and no Result Maps were found for the Mapped Statement
- 使用Mybatis时出错: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 'com.atguigu.atcrowdfunding.p
- FAQ(15):A query was run and no Result Maps were found for the Mapped Statement 'com.smbms.dao.UserMa
- A query was run and no Result Maps were found
- A query was run and no Result Maps were found
- org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the
- MyBatis报错:Result Maps collection already contains value for .....
- mybatis报错Result Maps collection already contains value for
- mybatis中Invalid bound statement (not found) 和 Result Maps collection already contains value for...错误解决方案
- 报错:No result defined for action and result input
- No default view was found for object type 10201 and query type 2
- 10进制和其他进制的转换
- 不用+号,实现a+b
- Redis学习笔记——(四)Redis集群调整
- caffe2 下载预训练模型需要注意的问题
- java 内部类
- Mybatis报错—— A query was run and no Result Maps were found for the Mapped Statement
- OpenStack云计算实战手册 第2版.pdf 免费下载
- 纸牌博弈问题 动态规划
- RecyclerView优雅设置边距
- HTML5 a标签的download属性
- xm、midi音频格式文件互相转化方法及工具
- Spring整合shiro
- JAVA----集合类——Map集合
- PHP下MySQL的基本使用函数