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 ...
随机推荐
- c#之初识结构(Struct)
C# 结构(Struct) 首先结构是值类型数据结构.它使得一个单一变量可以存储各种数据类型的相关数据.struct 关键字用于创建结构.通俗说:结构就是一个可以包含不同数据类型的集合.它是一种可以自 ...
- android studio 3.2 查看Deveice Monitor
View菜单下面的 Tool Windows 下面的 Devecie File Explorer
- java图片上传,通过MultipartFile方式,如果后台获取null检查是否缺少步骤
本方法基于springMvc 1.首先需要在webap下创建images 2.在springmvc.xml上引入 <bean id="multipartResolver" c ...
- flask框架-大结局
flask-script 用于实现类似于django中 python3 manage.py runserver ...类似的命令. 安装 pip3 install flask-script 使用: f ...
- 【转】Rendering Problems The following classes could not be instantiated
xml 设计时警告 打开es/values/目录下styles.xml文件. 把:<style name="AppTheme" parent="Theme.AppC ...
- IDEA查看接口的所有实现类
查看实现类 接口下右键Diagrams->Show Diagram,选中接口右键Show Implementations 或接口下按Ctrl+H: 或接口类名左边按钮:
- Python笔记_第三篇_面向对象_2.构造函数和析构函数(含self说明)
1. 构造函数: 为什么要有构造函数? 打一个比方:类的创建就是好比你创建了好了一种格式的房间,你租给上一个住户的后,里面会对方很多“垃圾”和不规则的物品摆放.构造函数就是下一个住户再使用的时候进行物 ...
- gcc -c xx.c 选项讲解
-c选项表示编译.汇编指定的源文件(也就是编译源文件),但是不进行链接.使用-c选项可以将每一个源文件编译成对应的目标文件. 目标文件是一种中间文件或者临时文件,如果不设置该选项,gcc 一般不会保留 ...
- typescript-学习使用ts-2
解构赋值 数组解构 let input = [1, 2]; let [first, second] = input; console.log(first); // outputs 1 console. ...
- 多标签图像分类任务的评价方法-mAP
http://blog.sina.com.cn/s/blog_9db078090102whzw.html 多标签图像分类(Multi-label Image Classification)任务中图片的 ...