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 ...
随机推荐
- 使用图数据库 Nebula Graph 数据导入快速体验知识图谱
本文由 Nebula Graph 实习生@王杰贡献. 最近 @Yener 开源了史上最大规模的中文知识图谱——OwnThink(链接:https://github.com/ownthink/Knowl ...
- Python程序中的线程操作(线程池)-concurrent模块
目录 Python程序中的线程操作(线程池)-concurrent模块 一.Python标准模块--concurrent.futures 二.介绍 三.基本方法 四.ProcessPoolExecut ...
- 计量经济与时间序列_关于Box-Jenkins的ARMA模型的经济学意义(重要思路)
1 很多人已经了解到AR(1)这种最简单的时间序列模型,ARMA模型包括AR模型和MA模型两个部分,这里要详细介绍Box-Jenkins模型的观念(有些资料中把ARMA模型叫做Box-Jenkins模 ...
- 控制台输出<迷你DVD管理>
使用顺序.选择.循环.跳转语句 数组 功能实现菜单显示和切换 输入的数字不符合要求直接退出程序 用户可以选择新增.查看. 删除.借出.归还.退出 思路分析 使用switch语句实现菜单选择 使用do- ...
- 数据处理——One-Hot Encoding
一.One-Hot Encoding One-Hot编码,又称为一位有效编码,主要是采用位状态寄存器来对个状态进行编码,每个状态都由他独立的寄存器位,并且在任意时候只有一位有效. 在实 ...
- 有关iOS热更新
iOS热更新的几篇文章,看完这几篇,自己集成一下.下面说一下我集成时遇到的问题. 这是原作者的JSPatch的讲解的文章:<JSPatch – 动态更新iOS APP>.<JSPat ...
- SpringBoot项目启动之前操作,启动之后操作
1.在Bean对象初始化之前可以做的操作 @Component public class InitBean implements BeanDefinitionRegistryPostProcessor ...
- Python语言学习:列表常用的方法
python 列表常用的方法 1.append( ):用于在列表末尾添加新的对象 list.appent(obj) #obj:添加到列表末尾的对象 #!/usr/bin/python aList = ...
- mysql 数据库保存\n 微信分享时不能换行
主要因为保存的是\n 但是查询出来是\\n 所以需要把\\n替换为\n即可(不转换的话不会换行并且显示\n)
- js强制浏览器重新渲染页面
今天遇到一个浏览器兼容性问题,大致原因就是在用某一个前端框架做分页时,由于是使用的jQuery的hide和show方法,其本质是为某个iframe加上一个display=none,这在chrome中是 ...