MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'
在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的....... ,写在映射文件中完全没用,实在没办法了,找我的牛老师 ^v^ 解决一下,后来在 映射文件的对应接口的方法的参数前加注解 @Param 就解决了这个困扰了我很久的问题,解释是:如果要把传入的参数在 ‘test’ 中比较,参数前加上注解 @Param('参数名') ,如果不加注解,它将在比较时,用参数调用get方法获得值,因为不是对象,所以也就报错了,我之前是用实体类包数据包装在进行传入比较的。。。。。还是记住这个坑吧。。。。。
接口代码:
List<User> selectByUserState(@Param("userState") int userState);
映射文件:
<select id="selectByUserState" parameterType="Integer" resultType="com.nf.lc.entity.User">
select * from user
<where>
<if test="userState == 1 or userState == 0">
user_state = #{userState}
</if>
</where>
</select>
希望你看到这篇博客能解决这个问题。
学无止境(LC)
MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'的更多相关文章
- MyBatis查询传一个参数时报错:There is no getter for property named 'sleevetype' in 'class java.lang.Integer
用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class jav ...
- Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'。
Mybatis找不到参数错误:There is no getter for property named 'categoryId' in 'class java.lang.Integer'. 错误Li ...
- Mybatis报错: There is no getter for property named xxx
在mapper文件中函数的形参上加上注解. 例如: 出现了如下错误:核心错误提示就是There is no getter for property named xxx ### Error qu ...
- mybatis There is no getter for property named 'xx' in 'class java.lang.String
转载自://http://www.cnblogs.com/anee/p/3324140.html 用mybatis查询时,传入一个字符串传参数,且进行判断时,会报 There is no getter ...
- Mybatis中传参包There is no getter for property named 'XXX' in 'class java.lang.String'
Mybatis中传参包There is no getter for property named 'XXX' in 'class java.lang.String' 一.发现问题 <select ...
- mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long'
mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long' 当使用mybatis进行传参的时候 ...
- Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'
错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'socialCode' in 'class java.lang.String'
异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Refl ...
- Mybatis问题:There is no getter for property named 'unitId' in 'class java.lang.String'
Mybatis遇到的问题 问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.re ...
随机推荐
- Python学习中的随笔,好记性不如烂笔头
本文 为博主看了 vamei 的blog 写下的随笔 . 致敬Vamei 1.type() 可以显示参数的类型 如 : a=12 type(a) 为 int 2.python的基本类型 为 i ...
- look and say 外观数列的python实现
#look_and_say 外观数列 如果我们把 1 作为Look-and-say 数列的第一项,那么,它的前几项是这样的: 1, 11, 21, 1211, 111221, 312211, 1311 ...
- CodeForces 263E Rhombus
洛谷题目页面传送门 & CodeForces题目页面传送门 给定一个$n$行$m$列的矩阵,第$i$行$j$列为$a_{i,j}$,以及一个常数$s\in\left[1,\left\lceil ...
- [原]livekd使用问题记录
sysinternal suite中的livekd.exe可谓神器.可以用来观察本地内核的一些状态,当然抓内核dump再合适不过了. 在使用livekd的时候遇到了一些问题,现总结如下: 使用live ...
- Jmeter学习前提:Jmeter安装
一.Jmeter下载 1. 前提:已经安装 jdk8+ 1.1 JDK下载 a. 进入jdk8+下载地址:https://www.oracle.com/technetwork/java/javase/ ...
- android 获得存储设备状态
1.获取存储器总大小,可用大小 File path= Environment.getExternalStorageDirectory();StatFs fs = new StatFs(path.get ...
- Uber坚持不盈利,葫芦里到底卖的是什么药?
近日,据媒体报道在美国科罗拉多州阿斯彭举办的<财富>科技头脑风暴大会上,Uber CEO达拉·科斯罗萨西表示,Uber无需在2019年下半年上市计划实施前保持盈利状态. 首先要明确一点的是 ...
- Apsara Clouder云计算技能认证:云数据库管理与数据迁移
一.课程介绍 二.云数据库的简介及使用场景 1.云数据库简介 1.1特点: 用户按存储容量和带宽的需求付费 可移植性 按需扩展 高可用性(HA) 1.2阿里云云数据库 RDS 稳定可靠,可弹性伸缩的在 ...
- python,openpyxl,读写excel文件
import openpyxl as oxl from openpyxl.utils import get_column_letter, column_index_from_string import ...
- 46)PHP,PHP语言为啥需要服务器
1)用户的 Web 浏览器发出 HTTP 请求,请求特定 Web 页面. 2)Web服务器收到.php 的请求获取该文件,并将它传到 PHP 引擎,要求它处理. 3)PHP 引擎开始解析脚本. 脚本中 ...