已解决: 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 database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'name' in 'class java.lang.String'
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'name' in 'class java.lang.String'
我的mapper中的select如下
<select id="listAllByName" resultType="edu.ifel.mybatis_test.entitys.Student">
SELECT sno,sname,ssex,sage
FROM Student
WHERE sname LIKE '%${name}%'
</select>
测试类中这样调用 :
String sname = "李";
List<Student> studentList = studentDAO.listAllByName(sname);
经过一番查找发现 此处将参数映射为String类型完全正确,但是在映射到<select>中时 '%${name}%' 相当于调用了 sname.name (即参数.name)
解决方案如下 :
方案一 : 只需将 '%${name}%' 变为 '%${_parameter}%' 即可
方案二 : 将 '%${name}%' 变为 '%${value}%' 也可
然后成功

已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'的更多相关文章
- 【Mybatis】mybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'areaName' in 'class java.lang.String'
mybatis查询报错: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pro ...
- mybatis之org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'time' in 'class java.lang.String'
mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsedCate" pa ...
- 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 ...
- org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'socialCode' in 'class java.lang.String'
异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Refl ...
- Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'zoneId' in 'class java.lang.String'
本文为博主原创,未经允许不得而转载: 异常展示: dao层定义的接口为: public int getClientTotal(); 在mybatis中的sql为: <select id=&quo ...
- org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String'
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...
- Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'company' in 'class java.lang.String'
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...
- nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'enterpriseId' in 'class java.lang.String'
错误信息: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for p ...
- MyBatis映射,抛出Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'oid' in 'class java.lang.String'
原因在于: 在MyBatis中使用动态语句的判断时,传入的参数(parameterType)为Java基本数据类型,获取的结果(resultType)为JavaBean对象,此时就会抛出该异常,此时可 ...
随机推荐
- EIGRP-3-EIGRP的多参数度量
带宽度量参数本身无法区分10Gbit/s及更高速率的接口.对1Gbit/s接口,默认延迟度量参数已设置为最低值1(10微妙).而且EIGRP承载的是经过换算的参数,每台路由器需要将其换算回再计算新开销 ...
- 手动添加git 到 右键菜单
1.通过在“运行”中输入‘regedit’,打开注册表. 2.找到[HKEY_CLASSES_ROOT\Directory\Background]. 3.在[Background]下如果没有[shel ...
- wms-springmvc-servlet.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- Java集合——集合框架Set接口
1.Set接口 一个不包含重复元素的collecyion.更确切的讲,set不包含满足e1.equals(e2)的元素e1和e2,并且最多包含一个null元素. 2.HashSet 类实现Set接口, ...
- Python编程实现USB转RS485串口通信
---作者吴疆,未经允许,严禁转载,违权必究--- ---欢迎指正,需要源码和文件可站内私信联系--- -----------点击此处链接至博客园原文----------- 功能说明:Python编程 ...
- 微信小程序时间处理问题
环境: 开发环境: 1. Mac OS 10.12.5 2. 微信Web开发者工具 v0.18.182200 测试环境: 1. iPhone 7 2. iOS 10.3.2 3. 微信 6.5.9 问 ...
- Android中渐变图片失真的解决方案
在android开发(尤其是android游戏开发)中有一个很严重的问题就是带有渐变效果的png图片会出现严重的banding(色带),鉴于这种情况,有几种可行的解决方法: 1.如果Activit ...
- Cypress测试工具
参考博客: https://testerhome.com/articles/19035 最近一段时间学习了cypress的测试工具, 她是一个端到端的测试web工具. 环境准备 1.工具:vs co ...
- nginx 中 root和alias
根本区别 一个请求的url= http://ip:port/path 在location中配置root和alias的区别: root是在location的正则之前拼接了路径 alias是在locati ...
- arcgis textsymbol overlap
arcgis textsymbol overlap textsymbol 重叠的问题 du?de? duration?? arcgis for javascript 如何避免 ...