mybaits错误解决:There is no getter for property named 'id' in class 'java.lang.String'
在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名。
正确的写法:
- <span style="font-size:18px;"> <!-- 用于查询运单号是否存在 -->
- <select id="isCargoBillNoExist" resultType="java.lang.Integer">
- select count(1)
- from t_entry_cargo_receiver_info
- where 1=1
- <if test="_parameter != null" >
- and cargo_bill_no = #{<span style="color:#ff0000;">_parameter</span>,jdbcType=VARCHAR}
- </if>
- </select></span>
错误的写法:
- <span style="font-size:18px;"> <!-- 用于查询运单号是否存在 -->
- <select id="isCargoBillNoExist" resultType="java.lang.Integer">
- select count(1)
- from t_entry_cargo_receiver_info
- where 1=1
- <if test="id != null" >
- and cargo_bill_no = #{<span style="color:#ff0000;">id</span>,jdbcType=VARCHAR}
- </if>
- </select></span>
评论区有人提到:
也可以在mapper的接口中,给这个方法的参数加上@param(value=“id”),这样就能在.xml中使用#{id,jdbcType=VARCHAR} 了。
这样也是可以的。
===============分割线===============
不过本文提到的错误,在实践中发现,并不都会出现。可能跟mybatis的版本有关系,就是说按照上文"错误"的写法来写,在某些版本中也是没有问题的,不必纠结。
如果出现了标题的错误,按照文中的方式解决即可。
示例:
mybaits错误解决: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' 错误
今天在修改一个关于mybtis语句时,偶然发现的一个错误 There is no getter for property named 'id' in class 'java.lang.String' ...
- 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 ...
- 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>标签 ...
- mybaits错误解决:There is no getter for property named 'parentId ' in class 'java.lang.String'
在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 比如mapper中如下方法,只有一个String值 publ ...
- 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报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'
最近在练习MyBatis时 进行姓名的模糊查询时候出现 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...
- There is no getter for property named 'userId' in 'class java.lang.String'
[ERROR] 2017-01-18 04:37:06:231 cn.dataenergy.common.CenterHandlerExceptionResolver (CenterHandlerEx ...
- Mybatis问题:There is no getter for property named 'unitId' in 'class java.lang.String'
Mybatis遇到的问题 问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.re ...
随机推荐
- python005 Python3 注释
Python3 注释确保对模块, 函数, 方法和行内注释使用正确的风格Python中的注释有单行注释和多行注释:Python中单行注释以 # 开头,例如:: # 这是一个注释 print(" ...
- HDU-1858-Max Partial Value I,有坑点,不难;
Max Partial Value I Time Limit: 1000/5000 MS (Java/Others) Memory Limit: 32768/65535 K (Java/Othe ...
- CodeForces - 592D Super M 题解
题目大意: 一棵树 n个点 有m个点被标记 求经过所有被标记的点的最短路径的长度以及起点(如有多条输出编号最小的起点). 思路: 1.当且仅当一个点本身或其子树中有点被标记时该点在最短的路径上因此,可 ...
- bzoj1190 [HNOI2007]梦幻岛宝珠 动态规划
给你N颗宝石,每颗宝石都有重量和价值.要你从这些宝石中选取一些宝石,保证总重量不超过W,且总价值最大为,并输出最大的总价值.数据范围:N<=100;W<=2^30,并且保证每颗宝石的重量符 ...
- [NOIP2002] 提高组 洛谷P1033 自由落体
题目描述 在高为 H 的天花板上有 n 个小球,体积不计,位置分别为 0,1,2,….n-1.在地面上有一个小车(长为 L,高为 K,距原点距离为 S1).已知小球下落距离计算公式为 d=1/2*g* ...
- msp430项目编程06
msp430中项目---设计扫描键盘 1.扫描键盘工作原理 2.电路原理说明 3.代码(显示部分) 4.代码(键盘驱动) 5.项目总结 msp430项目编程 msp430入门学习
- Xcode warning:Auto property synthesis will not synthesize property
iOS 警告提示如下: 添加 @dynamic告诉编译器这个属性是动态的,动态的意思是等你编译的时候就知道了它只在本类合成; 如下:
- 如何使用eclipse for c/c++ 配置环境编写第一个C程序
因为VS太大还要安装太多的插件,,,所以想用eclipse编写C语言... 1.下载eclipse for c/c++版本 去官网即可下载 https://www.eclipse.org/dow ...
- ssh 执行多条命令包含awk的用法
格式:ssh user@ip command 单条命令:ssh user@ip command1 多条命令:ssh user@ip "command1;command2" 不加双引 ...
- Meteor集合
在本教程中,我们将学习如何使用 MongoDB集合. 创建集合 我们可以使用以下代码来创建一个新的集合- meteorApp/client/main.js MyCollection = new Mon ...