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 比较的. ...
随机推荐
- .Net MVC 提示未能加载文件或程序集
最近在开发.Net MVC程序时,突然出现未能加载文件或程序集的错误, 错误1 错误2 猜测时由于引用了Swagger,导致Swagger依赖的组件版本和现有版本冲突(现在仍未确定是这个原因),浪费了 ...
- Unable to connect to web server 'IIS Express'(无法连接到Web服务器“IIS Express”)的解决方式-Jexus Manager
在运行微软示例工程eShopOnWeb时候, 在经过一段时间再运行启动报Error "Unable to connect to web server 'IIS Express'" ...
- jmeter返回结果出现乱码
这是我的问题: 请求的百度地址,返回的数据是中文乱码 去jmeter安装目录的bin下: 修改配置文件jmeter.properties 右键打开 ,查找:sampleresult.default.e ...
- python3之二年级上数学练习题生成
二年级上数学练习题生成 作为一个家长不容易啊 1 #coding:utf-8 2 import random 3 #小学二年级上数学练习(100以内加减乘) 4 #生成的题数 5 count = 50 ...
- csp 201809-1卖菜
问题描述 在一条街上有n个卖菜的商店,按1至n的顺序排成一排,这些商店都卖一种蔬菜. 第一天,每个商店都自己定了一个价格.店主们希望自己的菜价和其他商店的一致,第二天,每一家商店都会根据他自己和相邻商 ...
- UILabel的各种属性和方法
转自:http://liulu200888an.blog.163.com/blog/static/3498972320121214208542/ UILabel *label1 = [[UILabe ...
- day09 作业
简述定义函数的三种方式 空函数.无参函数.有参函数 简述函数的返回值 函数内部代码经过一系列的逻辑处理返回的结果 函数没有返回值,默认返回None 函数可以通过return返回出返回值 return可 ...
- [MySQL] 事务的ACID特性
事务的ACID特性: 原子性(atomicity):一个事务是一个不可分割的最小工作单位,事务中的所有操作要么都做,要么都不做. 一致性(consistency):事务前后数据的完整性必须保持一致.事 ...
- linux 重启 网络服务
设置网路ip等后 需要重启网路服务 debian: /etc/iinit.d/networking restart centos7: service network restart or syste ...
- 基于Anaconda编译caffe+pycaffe+matcaffe in Ubuntu[不用sudo权限]
目录 caffe 编译 环境 github下载caffe源码 依赖 修改源码的编译配置 报错 测试使用 pycaffe caffe matcaffe caffe 编译 环境 Ubuntu16.04 C ...