There is no getter for property named 'id' in 'class java.lang.Integer
There is no getter for property named 'id' in 'class java.lang.Integer
问题描述:
使用mybatis传入参数, 当参数类型是String ,Integer 等这些时。如果用他的 <if test="id != null and id != ''">
标签判断该参数是否为空,通常会爆There is no getter for property named ‘id’ in ‘class java.lang.Integer异常。
解决思路:
- 在接口中该方法的参数前加上@Param(“参数名”)注解。
例如:List<String> query(@Param(value="id") Integer id);
- 我百度的时候,发现还有人这样解决,不知是否可行,一并摘录下来:
在 xml文件中应该使用_parameter来代替参数名。
例如:
<select id="query" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from t_user
where 1=1
<if test="_parameter!= null" >
and id = #{_parameter}
</if>
</select>
总结:
其实这个问题并不是很大,但是容易一不小心就误犯;所以一定要小心谨慎。
There is no getter for property named 'id' in 'class java.lang.Integer的更多相关文章
- Bug--Mybatis报错:There is no getter for property named 'id' in 'class java.lang.Integer'
Mybatis 添加@Param("")注释就可以了
- 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 ...
- 关于mybtis 使用过程中发生There is no getter for property named 'id' in class 'java.lang.String' 错误
今天在修改一个关于mybtis语句时,偶然发现的一个错误 There is no getter for property named 'id' in class 'java.lang.String' ...
- 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 'sleevetype' in 'class java.lang.Integer
用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class jav ...
- mybaits错误解决:There is no getter for property named 'id' in class 'java.lang.String'
在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名. 正确的写法: <span style="f ...
- Mybatis-There is no getter for property named 'id' in 'class java.lang.String'
<mapper namespace="cn.telchina.standard.mapper.SysOrgnMapper"> <!-- <![CDATA[s ...
- There is no getter for property named 'id' in class 'java.lang.String'
https://blog.csdn.net/u011897392/article/details/46738747 使用mybatis传入参数,如果在mappin.xml中使用<if>标签 ...
- MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'
在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的. ...
随机推荐
- The connection string name is missing for the MySqlSiteMapProvider
在ASP.NET-WebForm程序中,添加SiteMapPath控件时出现问题,如下图所示: 解决办法:找到上图源文件指向的machine.config配置文件,将siteMap节点注释即可.
- C# 跨线程访问UI不报错,必须使用Invoke。
代码有时跨线程访问UI,修改按钮Enable属性不报异常.调试发现修改按钮属性的线程是Background,执行不报异常. 在窗体构造中添加 Control.CheckForIllegalCrossT ...
- background 设置文本框背景图
background 属性的作用是给元素设置背景,它是一个复合属性,常用的子属性如下: background-color 指定元素的背景颜色. background-image 指定元素的背景图像. ...
- Python - File - 第十八天
Python File(文件) 方法 open() 方法 Python open() 方法用于打开一个文件,并返回文件对象,在对文件进行处理过程都需要使用到这个函数,如果该文件无法被打开,会抛出 OS ...
- Java多线程——ThreadLocal类的原理和使用
Java多线程——ThreadLocal类的原理和使用 摘要:本文主要学习了ThreadLocal类的原理和使用. 概述 是什么 ThreadLocal可以用来维护一个变量,提供了一个ThreadLo ...
- wpf 工程生成dll
在WPF项目里,当工程里包含窗体时候, 不可以使用类库的方式生产dll,虽然系统支持引用exe 文件,但总是觉得不如dll习惯,后来发现,新建个项目,类型选择“WPF自定义类件库”,名称和工程名称相同 ...
- Android 拖动条/滑动条控件、星级评分控件
ProgressBar有2个子控件: SeekBar 拖动条控件 RatingBar 星级评分控件 1.拖动条控件 <SeekBar android:layout_width=" ...
- Win2003下安装PHP5.2.0+MySql5.0.27+PHPMyAdmin2.9.1的配置方法
先下载所需要安装的东东~~ PHP 5.2.0 官方下载地址:http://www.php.net/downloads.php mysql-5.0.27 官方下载地址:http://dev.mysql ...
- Linux---基本目录与文件命令
一.目录 1.显示工作目录命令pwd 2.改变工作目录命令cd 3.创建目录命令mkdir 二.文件 1.创建空文件命令touch 2.显示文件列表ls 3.复制文件或目录命令cp 4.删除文件或目录 ...
- 201871010110-李华《面向对象程序设计(java)》第十六周学习总结
博文正文开头格式:(2分) 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.co ...