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 ...
随机推荐
- Format - DateTime
1. Long Date/Short Date/Long Time/Short Time,可以在系统的“Region and Language”中找到相应设置: 2. ISO Format/Local ...
- centos apache 腾讯云ssl证书配置
首先向证书机构申请https证书,会得到证书和私钥,这里我以腾讯云证书安装为例(非常简单) 分两步走 1.申请 点击腾讯云控制台->产品模块下的ssl证书管理->点击申请证书(免费的,不要 ...
- Siebel学习笔记
Siebel(escript)的学习:1.Siebel的数据类型 Primitive(原始的)---Number,Integer,Hexadecimal(十六进制),Octal(八进制),Floati ...
- tensorflow读取jpg格式图片报错 ValueError: Only know how to handle extensions: ['png']; with Pillow installed matplotlib can handle more images
当运行mpimg.imread("img.jpg")时,spyder 出现如下错误: ValueError: Only know how to handle extensions: ...
- day009-IO流
什么叫流?就是数据的流动.以内存为基准,分为输入input和输出output.输入也叫做读取数据,输出也叫写出数据. 分类 按数据的流向分: 输入流.输出流 按数据类型分: 字节流.字符流 1. ...
- matlab中换行
若在命令窗口中,如果一条语句已经写完,需要换行,可以用"Shift+Enter", 如果一条语句没写完就想换行,可以使用"...+Enter".
- std::string::find_last_not_of
public member function <string> std::string::find_last_not_of C++98 C++11 string (1) size_t fi ...
- 使用shell调用python中的函数
最近遇到一个需求,需要通过shell调用python中的一个函数,发现其实也挺简单的: python脚本如下: test.py: import ConfigParser config = Config ...
- 推箱子Unity
逻辑首先有控制台写了一下. 需要注意的地方不少: 进一步,需要考虑3个层面的问题. 前面的位置是空地,成功点,墙,还是箱子. 前面是箱子的时候,箱子的前面是空地,墙,成功点,还是箱子. 当移动的时候, ...
- 可持久化线段树(主席树)快速简洁教程 图文并茂 保证学会。kth number例题
如果学不会也不要打我. 假设你会线段树 开始! --- 主席树也叫可持久化线段树 顾名思义,它能够保存线段树在每个时刻的版本. 什么叫每个时刻的版本?你可能对一棵普通线段树进行各种修改,这每种样子就是 ...