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 ...
随机推荐
- ezdpl:完全依赖脚本和ssh的自动化部署方案
ezdpl是easy deployment的简写,使用简单的ssh和shell脚本来部署.升级.回滚和重新配置linux服务器. 重要提示:警告:这个项目还处于测试过程中,请仔细阅读说明,并且自己承担 ...
- Android 多个activity之间的共享数据
最近打算做一个时间助手,一个service监听课表信息.课表信息可以通过另外的activity来设置,所以这里就涉及到了数据的同步问题.我设置后的信息必须同步到监听的信息去. 在java中我们用全局变 ...
- Django问卷调查项目思路流程
Django问卷调查项目思路流程: 1 后端思路 : 需求分析 ---- 找出各实体对应关系 ---- 设计model架构 ---- 统一资源封装 --- 提供资源API入口 ---- 设计项目实体功 ...
- 【Leetcode】【Easy】Add Binary
Given two binary strings, return their sum (also a binary string). For example,a = "11"b = ...
- python常用模块(二)
1.ConfigParser模块 用于生成和修改配置文档,在python3.x中变更为configparser 1 [DEFAULT] 2 ServerAliveInterval = 45 3 Com ...
- Opencv4android的Android Studio环境配置及项目实例下载
因为软件竞赛的项目会用到Opencv for Android,所以就研究了一下如何在Android Studio上配置Opencv4Android 环境概述: Android Studio 2.3 O ...
- Jmeter启动报错:unable to access jarfile ApacheJmeter.jar error 原因:下载的src包没有这个jar包,需下载binary包
安装好jdk并配置了环境变量,下载Jmeter包解压启动jemter.bat提示 unable to access jarfile ApacheJmeter.jar error 原因: 从官网 htt ...
- HDU 1521 指数型母函数
方法一: DFS 方法二:生成函数 每个数可以重复一定次数,求排列组合数,这是裸的指数型生成函数: #include <bits/stdc++.h> using namespace std ...
- Uva 12298 超级扑克2
题目链接:https://vjudge.net/problem/UVA-12298 题意: 1.超级扑克,每种花色有无数张牌,但是,这些牌都是合数:比如黑桃:4,6,8,9,10,,,, 2.现在拿走 ...
- 课堂笔记——循环语句-for
一.循环:多次执行某段代码. 二.循环四要素: 1.初始条件 2.循环条件 3.状态改变 4.循环体 三.for循环 1.语法: for(初始条件;循环条件;状态改变) { 循环体 } 2 ...