// 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. vs2015 web项目加载失败解决办法

    1.问题 ---------------------------Microsoft Visual Studio---------------------------Web 应用程序项目 XXWeb 已 ...

  2. 两种实现光标点插入range

    一.insertNode <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...

  3. [转]JSON.parse()和JSON.stringify()

    parse用于从一个字符串中解析出json对象,如 var str = '{"name":"huangxiaojian","age":&qu ...

  4. TextView的跑马灯效果(AS开发实战第二章学习笔记)

    TextView的跑马灯效果跑马灯用到的属性与方法说明singleLine 指定文本是否单行显示ellipsize 指定文本超出范围后的省略方式focusable 指定是否获得焦点,跑马灯效果要求设置 ...

  5. android之键盘转载

    显示键盘: EditText editText.setFocusable(true); editText.setFocusableInTouchMode(true); editText.request ...

  6. js 获取URL中参数

    function getQueryString() { var result = location.search.match(new RegExp("[\?\&][^\?\& ...

  7. UML面向对象建模基础

    一个比较好的UML教程PPT https://wenku.baidu.com/view/cf80902e26284b73f242336c1eb91a37f11132ac.html

  8. Linux下Apache HTTP Server 2.4.20安装

    一.创建software目录 mkdir /softwareer 二.下载apache源码包 wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4 ...

  9. 浅谈SAP Cloud for Sales 自动化

    在Jerry还在本科进行计算机理论知识学习时,我曾经把软件开发里的质量工程师(Quality Engineer)理解成是每天只是简单地做着运行开发人员编写好的软件,如果发现问题,通知开发人员去修改这种 ...

  10. Android进阶笔记14:3种JSON解析工具(org.json、fastjson、gson)

    一. 目前解析json有三种工具:org.json(Java常用的解析),fastjson(阿里巴巴工程师开发的),Gson(Google官网出的),其中解析速度最快的是Gson. 3种json工具下 ...