// Mapper.java
EmerEvent selectByAlarmId(Integer alarmId); // Mapper.xml
<select id="selectByAlarmId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from event
<where>
<if test="alarmId != null">
and alarm_id = #{alarmId,jdbcType=Integer}
</if>
</where>
</select>

由于只传了一个参数:alarmId,配置文件中对应的sql里使用if标签,然后报错:

nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'alarmId' in 'class java.lang.Integer'

解决办法:

1.将mapper配置文件中的sql语句中的if判断去掉

<select id="selectByAlarmId" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List" />
from event
where alarm_id = #{alarmId,jdbcType=Integer}
</select>

2.如果想要使用if标签,则将参数alarmId封装到对象或Map中即可

mybatis传单个参数,和<if>标签同时使用的问题的更多相关文章

  1. mybatis :xml文件中传入参数和if标签结合使用时要点

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...

  2. Mybatis查询select 传单个参数不识别,找不到

    今天, Mybatis查询select 传单个参数不识别,找不到 解决办法: 加上jdbc=varchar #{XXX,jdbc=VARCHAR}

  3. MyBatis的Mapper文件的foreach标签详解

    MyBatis的Mapper文件的foreach标签用来迭代用户传递过来的Lise或者Array,让后根据迭代来拼凑或者批量处理数据.如:使用foreach来拼接in子语句. 在学习MyBatis M ...

  4. 源码解析之 Mybatis 对 Integer 参数做了什么手脚?

    title: 源码解析之 Mybatis 对 Integer 参数做了什么手脚? date: 2021-03-11 updated: 2021-03-11 categories: Mybatis 源码 ...

  5. MyBatis的返回参数类型和查询结果遍历

    MyBatis的返回参数类型分两种 1. 对应的分类为: 1.1.resultMap: 1.2.resultType: 2 .对应返回值类型: 2.1.resultMap:结果集 2.2.result ...

  6. MyBatis 传List参数 nested exception is org.apache.ibatis.binding.BindingException: Parameter 'idList' not found.

    在MyBatis传入List参数时,MyBatis报错:nested exception is org.apache.ibatis.binding.BindingException: Paramete ...

  7. mybatis中String参数的传递

    mybatis中String参数的传递 Keywords selectKeywords(@Param("key") String key); 可以在mapper方法的参数钱添加 @ ...

  8. MyBatis动态SQL之一使用 if 标签和 choose标签

    bootstrap react https://segmentfault.com/a/1190000010383464 xml 中 < 转义 to thi tha <if test=&qu ...

  9. MyBatis的传入参数parameterType类型

    1. MyBatis的传入参数parameterType类型分两种 1. 1. 基本数据类型:int,string,long,Date; 1. 2. 复杂数据类型:类和Map 2. 如何获取参数中的值 ...

随机推荐

  1. oozie安装总结

    偶然的机会,去面试的时候听面试官讲他们的调度系统是基于hue+oozie,以前一直没有接触过,今天趁有空,尝试一下oozie 1.环境说明 cat /etc/issue  CentOS release ...

  2. visual studio code断点调试react

    在项目配置文件   .vscode\launch.json 中添加:   "sourceMaps": true,   "skipFiles": [   &quo ...

  3. linux 安装源码后的操作 ldconfig

    https://blog.csdn.net/cqkxboy168/article/details/8657487 知识点: .如果使用 ldd 命令时没有找到对应的共享库文件和其具体位置,可能是两种情 ...

  4. html5之hash

    http://blog.csdn.net/u012028371/article/details/67636395 原文:https://www.studyscript.com/Post/index/i ...

  5. 《C++ Primer Plus》读书笔记之二—复合类型

    二.第四章 复合类型  1.C-风格字符串:C-风格字符串具有一种特殊的性质:以空字符结尾,空字符被写成\0,其ASC||编码为0,用来标记字符串的结尾.例如: char dog[5]={'b','e ...

  6. openAI最近推出了一个新的语言模型 "GPT-2"

    [转]openAI最近推出了一个新的语言模型 "GPT-2",由于效果太好(?)几乎可以以假乱真,所以openAI正在犹豫是否把这个project完整release出来.(于是有人 ...

  7. Web博文目录

    前言 博客写的多了,自己翻起来也费劲,这里就进行一下整合. 以前设想自己做DBA,做运维,没想到最后还要走开发这条路,干一行就爱一行...学的扎实点,工作起来也会轻松.—— 送给奋斗的自己 1 Jav ...

  8. 解决zabbix3.4X图形页面中文乱码

    解决zabbix3.4X页面中文乱码 1.在windows的C:\Windows\Fonts找到字体文件simkai.ttf2.在zabbix服务器上找到zabbix默认字体文件graphfont.t ...

  9. 邮件营销巧妙添加GIF让您的邮件动起来

    动态图片远比静态图片要吸引人,因此近年来,一些营销人员也开始越来越频繁的使用GIF动画图片,适当的穿插和点缀动态图片,能够生动形象的表达出 主题,并且时不时令读者忍俊不禁.尤其是做邮件营销的,如果能在 ...

  10. 50. Pow(x, n) (recursion)

    Implement pow(x, n), which calculates x raised to the power n (xn). Example 1: Input: 2.00000, 10 Ou ...