mybatis报错:sql中有条件语句时出现属性没有getter的异常
Mybatis问题:在使用条件语句动态设置SQL语句时出现如下错误
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'
at books.com.BooksApplicationTests.getBookTest(BooksApplicationTests.java:56)
解决方法:
在映射接口中,方法的中的参数添加@Param(“parameter name”)即可。
例子:
映射接口:
public interface BookMapper {
Book getBookById(int id);
Book getBook(@Param("id") int id);
}
映射配置文件:
<select id="getBook" parameterType="int" resultType="books.com.boot.model.Book">
SELECT * FROM book
<where>
<if test="id>0">id=#{id}</if>
</where>
</select> 若映射配置文件这样写则不需要添加@Param注解
<select id="getBookById" parameterType="int" resultType="books.com.boot.model.Book">
SELECT * FROM book WHERE id=#{id}
</select>
mybatis报错:sql中有条件语句时出现属性没有getter的异常的更多相关文章
- 已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'
最近在练习MyBatis时 进行姓名的模糊查询时候出现 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...
- Mybatis中动态SQL多条件查询
Mybatis中动态SQL多条件查询 mybatis中用于实现动态SQL的元素有: if:用if实现条件的选择,用于定义where的字句的条件. choose(when otherwise)相当于Ja ...
- mybatis报错:Invalid bound statement (not found)
mybatis报错:Invalid bound statement (not found)的原因很多,但是正如报错提示一样,找不到xml中的sql语句,报错的情况分为三种: 第一种:语法错误 Java ...
- Springboot项目下mybatis报错:Invalid bound statement (not found)
mybatis报错:Invalid bound statement (not found)的原因很多,但是正如报错提示一样,找不到xml中的sql语句,报错的情况分为三种: 第一种:语法错误 Java ...
- mybatis报错Mapped Statements collection does not contain value for com.inter.IOper
首页 > 精品文库 > mybatis报错Mapped Statements collection does not contain value for com.inter.IOper m ...
- mybatis报错 Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types () or values ()
mybatis报错 Error instantiating interface com.atguigu.mybatis.dao.DepartmentMapper with invalid types ...
- 【.net core 入坑】.net core 3.0 报错:在 FETCH 语句中选项 NEXT 的用法无效
目录 1.事故现场: 2.分析及解决方案: 1.事故现场: 在项目中使用.net core 3.0,在EF链接sqlserver2008,在程序中使用了分页用的skip和take,程序报错: 在 FE ...
- oracle+mybatis报错:BindingException("Invalid bound statement (not found): ")
oracle+mybatis报错:BindingException("Invalid bound statement (not found): ") 从mysql转到oracle数 ...
- mybatis报错:A query was run and no Result Maps were found for the Mapped Statement、、Property [login_ip] not found on type [com.thinkgem.jeesite.common.permission.entity.PremissUser]问题解决
今天在做ssm项目的时候出现了: 先是出现 了错误: mybatis报错:A query was run and no Result Maps were found for the Mapped St ...
随机推荐
- Ubuntu上使用vnc服务
http://www.aichengxu.com/linux/8479752.htm 1. sudo apt-get install x11vnc 2. sudo x11vnc -storepassw ...
- matlab 中“newff” 函数的参数设置
matlab 中"newff" 函数的使用方法技巧|和各参数的意义 先来一个简单的源程序让大家练习一下: % Here input P and targets T define a ...
- win10安装mxnet cuda9.0-gpu版
类似于上一篇文章 Anaconda3.6 python3.6.5 cuda9.0+ cudnn7.0 安装MXNet 1.设置清华源 conda config --prepend cha ...
- oracle备份恢复
1.oracle文件备份恢复 /etc/oraInst.loc /etc/oratab /home/oracle 家目录 /oracle 安装目录 /usr/local/bin/dbhome /usr ...
- June 02nd 2017 Week 22nd Friday
A burden of one's choice is not felt. 爱挑的担子不嫌重. When doing things I love to do, I seldom feel tired ...
- (String)、toString()与String.valueOf()的区别
(String).Object.toString()正常情况下跟String.valueOf()没有区别. 但当Object是null的时候.toString会抛出异常.valueOf返回" ...
- LA 3353 最优巴士线路设计
给出一个 n 个点的有向图,找若干个圈,是的每个结点恰好属于一个圈.要求总长度尽量小. 三倍经验题 Uva 12264,HDU 1853 这题有两种解法,一是匹配: 每个点只在一个圈中,则他有唯一的前 ...
- react开发环境准备
使用reactjs,我们有两种方式 一种是通过script标签引入reactjs,这是一种比较古老的编码方式了, 如果我们的项目比较大,你会对项目js进行拆分,然后页面就会通过script标签加载很多 ...
- 对selenium自动化框架重构
近期在编写自动化脚本的时候发现以前写的部分不是特别友好,在此进行重构.废话不说 搭建自动化框架,首先先理清思路: 使用的技术python+unittest+selenium+excel 文件目录有: ...
- XCode项目配置可访问 非 https 接口的方法
打开项目的info.plist文件,右键- open as sourceCode .在代码中添加: <key>NSAppTransportSecurity</key> < ...