mybatis传单个参数,和<if>标签同时使用的问题
// 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>标签同时使用的问题的更多相关文章
- mybatis :xml文件中传入参数和if标签结合使用时要点
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...
- Mybatis查询select 传单个参数不识别,找不到
今天, Mybatis查询select 传单个参数不识别,找不到 解决办法: 加上jdbc=varchar #{XXX,jdbc=VARCHAR}
- MyBatis的Mapper文件的foreach标签详解
MyBatis的Mapper文件的foreach标签用来迭代用户传递过来的Lise或者Array,让后根据迭代来拼凑或者批量处理数据.如:使用foreach来拼接in子语句. 在学习MyBatis M ...
- 源码解析之 Mybatis 对 Integer 参数做了什么手脚?
title: 源码解析之 Mybatis 对 Integer 参数做了什么手脚? date: 2021-03-11 updated: 2021-03-11 categories: Mybatis 源码 ...
- MyBatis的返回参数类型和查询结果遍历
MyBatis的返回参数类型分两种 1. 对应的分类为: 1.1.resultMap: 1.2.resultType: 2 .对应返回值类型: 2.1.resultMap:结果集 2.2.result ...
- 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 ...
- mybatis中String参数的传递
mybatis中String参数的传递 Keywords selectKeywords(@Param("key") String key); 可以在mapper方法的参数钱添加 @ ...
- MyBatis动态SQL之一使用 if 标签和 choose标签
bootstrap react https://segmentfault.com/a/1190000010383464 xml 中 < 转义 to thi tha <if test=&qu ...
- MyBatis的传入参数parameterType类型
1. MyBatis的传入参数parameterType类型分两种 1. 1. 基本数据类型:int,string,long,Date; 1. 2. 复杂数据类型:类和Map 2. 如何获取参数中的值 ...
随机推荐
- ElementUI组件库常见方法及问题汇总(持续更新)
本文主要介绍在使用ElementUI组件库的时候,常遇见的问题及使用到的方法,汇总记录便于查找. 1.表单 阻止表单的默认提交 <!-- @submit.native.prevent --> ...
- HTML总结摘要
一 概述 1.什么是HTML? HyperText Markup Language,超文本标记语言,客户端技术的技术,负责页面展示. 2.HTML的特点 标签不区分大小写. 3.请求地址 HTML是客 ...
- 文字编辑器FCKeditor 简介以及基本配置和使用方法
什么是FCKeditor FCKeditor是一个专门使用在网页上属于开放源代码的所见即所得文字编辑器.它志于轻量化,不需要太复杂的安装步骤即可使用.它可和PHP.JavaScript.ASP.ASP ...
- Ubuntu / Raspberry 下切换GCC版本
目前Ubuntu 自带的GCC版本为4.6,遗憾的是在实际使用时,反而版本越高越好问题越多,所以,一旦遇到编译问题时最好先检查你下载的工程里的readme,默认的编译器版本是否为当前的安装版本,如果不 ...
- Python log 模块介绍
刚用Python log模块写了一个例子,记录一下. import logging import logging.handlers import os from datetime import dat ...
- 【Leetcode】【Medium】Binary Tree Zigzag Level Order Traversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to ...
- 【Leetcode】【Medium】Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- 在IIS7上导出所有应用程序池的方法 批量域名绑定
在IIS7+上导出所有应用程序池的方法:%windir%/system32/inetsrv/appcmd list apppool /config /xml > c:/apppools.xml ...
- 三、基于任务的异步模式(TAP),推荐使用
一.引言 在上两个专题中我为大家介绍.NET 1.0中的APM和.NET 2.0中的EAP,在使用前面两种模式进行异步编程的时候,大家多多少少肯定会感觉到实现起来比较麻烦, 首先我个人觉得,当使用AP ...
- 一个U盘黑掉你:TEENSY实战
从传统意义讲,当你在电脑中插入一张CD/DVD光盘,或者插入一个USB设备时,可以通过自动播放来运行一个包含恶意的文件,不过自动播放功能被关闭时,autorun.inf文件就无法自动执行你的文件了.然 ...