最近在练习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'的更多相关文章

  1. 【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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ' ...

  7. 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 ' ...

  8. 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 ...

  9. 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对象,此时就会抛出该异常,此时可 ...

随机推荐

  1. java 集合解析

    Set集合,放的元素不能重复,请问它的判断重不重复是怎么实现的? 比如说:ArrayList 和 Vector 是用数组的方式存储的Set里的 hashSet 和TreeSet是用什么方式存储的?怎么 ...

  2. Windows 新增 Sublime Text3 右键快捷方式

    Win10 创建 Sublime Text 3 右键快捷方式 Windows + R 输入 regedit 打开注册表编辑器: 依次找到 计算机\HKEY_CLASSES_ROOT\*\shell: ...

  3. CF213E Two Permutations 线段树维护哈希值

    当初竟然看成子串了$qwq$,不过老师的$ppt$也错了$qwq$ 由于子序列一定是的排列,所以考虑插入$1$到$m$到$n-m+1$到$n$; 如何判断呢?可以用哈希$qwq$: 我们用线段树维护哈 ...

  4. spring容器中的beanName

    1. 一个类实现多个接口 如下图中的JobService.java, 此时这个beanName=jobService,  没有包名,类名字首字母小写 可以使用下面三种方式获得这个bean IProce ...

  5. Scrapy(爬虫应用框架)安装配置

    运行平台:Windows Python版本:Python3.x 一.Scarpy 简介 Scrapy是一个为了爬取网站数据提取结构性数据而编写的应用框架,可以应用于数据挖掘,信息处理或存储历史数据等一 ...

  6. SPA 介绍

    SQL 性能分析器(SPA)工具概览 作为 Oracle Real Application Testing 选件/特性,这篇文章将提供一个关于 SQL 性能分析器(SPA)工具的简要概览.这是此系列的 ...

  7. arch安装软件提示包损坏

    错误:lib32-libjpeg6-turbo: signature from "Colin Keenan <colinnkeenan@gmail.com>" is u ...

  8. 冷笑话,idea 按删除键就是undo?

    第一反应是keymap被改了,一看 那么,看起来就是alt出问题了 解决方法 在公司换一个键盘或者狂按alt

  9. AD Framework 发布(一)

      1.     EF Code First 发布时,需要配置数据库账号,账号需要存在服务器角色中具备 diskadmin,public,sysadmin 权限. 2.    数据库不存在时,会通过数 ...

  10. Mysql5.7.6安装和主从配置手册

    Mysql5.7.6+ 安装手册 linux server版本   1.下载 http://dev.mysql.com/downloads/mysql/#downloads  2. 检查库文件是否存在 ...