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 ...
随机推荐
- COJ 1211 大整数开平方
手写求大整数开根号所得到的值,具体计算过程参考别人的资料,最后利用java的大整数得到答案 别人博客链接:http://www.cnblogs.com/Rinyo/archive/2012/12/16 ...
- iOS时钟,秒针扫秒样式
昨天做一个时钟小demo,发现了一些问题. 描述能力有限,我封装好了一个时钟框架,朋友们可以参考 https://github.com/qianlishun/ClockView 点击这里可以 ...
- 转载:用vector保存对象时保存指针的优点, 以及reserve的使用
#include <vector> #include <stdio.h> class A { public: A() { printf("A()/n"); ...
- poj3905 2sat!
这次已经不是2sat的问题了,相信2sat已经不是问题了,最后一题2sat,竟然跪在输入上! 千万注意scanf(%c)!读入!!!!有空格也读啊!!!读入+ -一定要用字符读啊??笨死算了!被人水死 ...
- 第18章:MYSQL分区
第18章:分区 目录 18.1. MySQL中的分区概述 18.2. 分区类型 18.2.1. RANGE分区 18.2.2. LIST分区 18.2.3. HASH分区 18.2.4. KEY分区 ...
- CodeForces 596A Wilbur and Swimming Pool
水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> u ...
- T1503 愚蠢的宠物 codevs
http://codevs.cn/problem/1503/ 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 大家都知道,sh ...
- Teamviewer ubuntu 提示 TeamViewer Daemon is not running
http://blog.csdn.net/laohuang1122/article/details/12657343 Ubunut 12.04下面安装了Teamviewer,刚安装完启动是没有问题的, ...
- 畅通project续
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Submission(s) ...
- SQL - 创建一个学生表,要求有主键约束和非空约束
CREATE TABLE [dbo].[Student] ( [ID] [int] NOT NULL, [Name] [nchar](10) NOT NULL, [Age] [int] NOT NUL ...