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的更多相关文章

  1. Bug--Mybatis报错:There is no getter for property named 'id' in 'class java.lang.Integer'

    Mybatis 添加@Param("")注释就可以了

  2. 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 ...

  3. 关于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' ...

  4. 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 ...

  5. 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 ...

  6. mybaits错误解决:There is no getter for property named 'id' in class 'java.lang.String'

    在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名. 正确的写法: <span style="f ...

  7. Mybatis-There is no getter for property named 'id' in 'class java.lang.String'

    <mapper namespace="cn.telchina.standard.mapper.SysOrgnMapper"> <!-- <![CDATA[s ...

  8. 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>标签 ...

  9. MyBatis if test 传入一个数字进行比较报错 There is no getter for property named 'userState' in 'class java.lang.Integer'

    在写MyBatis映射文件中,我要传入一个 int 类型的参数,在映射文件中用 'test' 中进行比较,我花了很长时间百度,发现都是不靠谱的方法,有把数字在比较时转成字符串用 equals 比较的. ...

随机推荐

  1. Linux CentOS内核升级

    1. 说明 正在使用的阿里云服务器报了几个内核漏铜,使用自带[一键修复]需要额外的支付费用,所以尝试采用升级系统内核的方式来修复漏洞. 1.1 服务器参数 操作系统:CentOS 7.4 64位 当前 ...

  2. Python requests库的使用(二)

    1.请求异常处理 请求异常类型: 请求超时处理(timeout): 实现代码: import requestsfrom requests import exceptions        #引入exc ...

  3. 洛谷 p1008三连击

    洛谷 p1008三连击 题目背景 本题为提交答案题,您可以写程序或手算在本机上算出答案后,直接提交答案文本,也可提交答案生成程序. 题目描述 将1,2, ⋯,9共99个数分成3组,分别组成3个三位数, ...

  4. vs2015 创建MVC项目

    直接上图吧! 第一步:新建项目 第二步:选择模板 第三步:系统自动生成项目文件 第四步:创建控制器(C):找到Controllers文件夹->右键->添加->控制器 第五步:添加控制 ...

  5. 使用IDEA创建Spring Boot项目

    第一步:根据1.2.3点鼠标哦: 第二步:点击Next 第三步:按红框框选,然后Next 第四步:选个保存路径,然后Next 第五步:点击Finish就大功告成了

  6. npm install 报错 -4048

    方法1: 删除npmrc文件. 强调:不是nodejs安装目录npm模块下的那个npmrc文件,而是在C:\Users\{账户}\下的.npmrc文件. 方法2: https://www.jiansh ...

  7. loadView的原理

    其他的小记: 1.控制器的view是怎么创建的 当外界第一次使用当前控制器的view时,会调用当前一个方法loadView,创建控制器的view: 控制器的view是懒加载的,什么时候使用,什么时候才 ...

  8. https://support.microsoft.com/zh-cn/help/2290714/error-message-when-you-install-office-2010-on-a-windows-7-based-comput

    Error message when you install Office 2010 on a Windows 7-based computer "The installation of M ...

  9. Python 报错 MySQLdb._exceptions.OperationalError: (2059, )

    Python连接MySQL数据时:报错提示MySQLdb._exceptions.OperationalError: (2059, <NULL>). Python包: mysqlclien ...

  10. 在linux下配置jupyter notebook,本地浏览器访问

    1.安装jupyter notebook pip install jupyter 2.生成配置文件 jupyter notebook --generate-config 3.设置登陆密码并生成秘钥 s ...