mybatis there is no getter named forInteger
JAVA就业套餐课:https://edu.csdn.net/combo/detail/1230
一:发现问题
sql动态语句中如果 parameterType="int"
<select id="sel_campusinfo" parameterType="int" resultType="Campusinfo">
select cmpid,cmpname from campusinfo where state!='d' and cmpid=#{cmpid}
</select>
是正确的,但是如果加上if test
<select id="sel_campusinfo" parameterType="int" resultType="Campusinfo">
select cmpid,cmpname from campusinfo where state!='d' and cmpid!=0
<if test="cmpid!=0">and cmpid=#{cmpid}</if>
</select>
则报错:
There is no getter for property named 'cmpid' in 'class java.lang.Integer'
出错原因:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取Integer.cmpid。Integer对象没有cmpid属性。如果不解析参数,mybatis自动识别传入的参数,不会报错。
二:解决办法
1.修改select语句
<select id="sel_campusinfo" parameterType="int" resultType="Campusinfo">
select cmpid,cmpname from campusinfo where state!='d' and cmpid!=0
<if test="_parameter!=0">and cmpid=#{_parameter}</if>
</select>
参数名全部改为_parameter。
2.不修改sql,只修改接口
接口类:
Campusinfo sel_campusinfo( int cmpid);
改为:
Campusinfo sel_campusinfo(@Param(value="cmpid") int cmpid);
3.可以将参数包装在hashmap或者对象中作为参数
---------------------
作者:cclovett
来源:CSDN
原文:https://blog.csdn.net/cclovett/article/details/12855505
版权声明:本文为博主原创文章,转载请附上博文链接!
mybatis there is no getter named forInteger相关推荐
- Mybatis There is no getter for property named 'XXX' in 'class java.lang.XXX
Mybatis查询 使用Mybatis查询时,其参数可以是基本数据类型或者像Integer和String这样的简单的数据对象,也可以是复杂对象(一般是指JavaBean)或者map等,当使用基本数据类 ...
- mybatis There is no getter for property named 'xx' in 'class java.lang.String
用mybatis查询时,传入一个字符串传参数,且进行判断时,会报 Java代码 There is no getter for property named 'moduleCode' in 'cla ...
- MyBatis There is no getter for property named ‘xxx‘ in ‘class xxx‘问题解决
问题描述: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Re ...
- mybatis There is no getter for property named '*' in 'class java.lang.String
1.原因 server层 xxxx.get("1234") map <if test="aaa != null and aaa.id != null and ...
- There is no getter for property named 'xxx' in 'class.....'
mybatis There is no getter for property named 'xxx' in 'class.....' 在确定该字段在entity中添加了get set方法之后,通常 ...
- 3种常见的数据脱敏方案
往期热门文章:1.BigDecimal使用不当,造成P0事故! 2.改造BeanUtils,优雅实现List数据拷贝 3.SpringBoot 启动时自动执行代码的几种方式,还有谁不会?? 4.让人上 ...
- mybatis报错There is no getter for property named '***' in 'class ***'
mybatis报错There is no getter for property named '***' in 'class ***', 检查一看是xml中映射字段拼写错误,大小写. 有的时候用插件生 ...
- 异常处理:Mybatis报错:There is no getter for property named ‘xxxx‘ in ‘class xxx‘
异常处理:Mybatis报错:There is no getter for property named 'xxxx' in 'class xxx' 参考文章: (1)异常处理:Mybatis报错:T ...
- Mybatis中传参包There is no getter for property named XXX in class java.lang.String
一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType=&quo ...
最新文章
- 房价波动5%很正常 房地产市场绝不会崩盘
- 【Java】MapReduce 程序五步走的思想详细描述
- MySQL查看当前的连接信息
- 解决WIN10下MatlabR2016a、VeriStand2018和Labview2018的联合仿真的问题
- 【模拟器】网工福音!华三模拟器HCL升级,部分功能超越eNSP和EVE!
- cpu计算机性能指标有哪些,CPU性能指标有哪些
- 电商 购物车-订单-支付流程
- 如何配置 SSH 免密码登录
- php下载链接 迅雷下载,php实现把url转换迅雷thunder资源下载地址的方法
- 如何使用HTML制作tab选项卡
- 结构型设计模式(7种)
- ORB-SLAM2代码详解09: 闭环线程LoopClosing
- 利用Cookie显示上次登录时间
- juicy-potato Windows提权之访问令牌操纵
- 便携式双向无线电设备-市场现状及未来发展趋势
- 基于JavaSDK实现微信支付,springboot封装签名过程,直接调用controller层实现调起微信支付接口
- 马云说完新零售,范驰开讲新店商
- 【数据库】查询所有同学的学号、姓名、选课数、总成绩(左外连表查询)
- c语言圆周率小数点后500万位,活久见!德科学家整理出圆周率小数点后500万位数字...
- 阿里云centos环境之被dos,syn攻击策略和排查方法,持续更新九
热门文章
- 栈解析html文件,利用栈将html源码解析为节点树
- nodejs 定时 mysql_nodejs 使用 mysql
- 多线程基础-实现多线程的两种方式(二)
- 多线程基础-基本概念(一)
- poj 2492 A Bug's Life
- 极简代码:1012 数字分类 (20分)
- python遍历excel_python遍历文件读取并写结果到excel
- [java][工具类][Collections]
- python笔记之序列(set的基本使用和常用操作)
- recyclerview item点击无效_Android列表布局专题(一)RecyclerView