已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property nam

最近在练习MyBatis时 进行姓名的模糊查询时候出现java

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以下apache

<select id="listAllByName" resultType="edu.ifel.mybatis_test.entitys.Student"> SELECT sno,sname,ssex,sage FROM Student WHERE sname LIKE '%${name}%'
  </select>

测试类中这样调用 :mybatis

    String sname = ""; List<Student> studentList = studentDAO.listAllByName(sname);

 

通过一番查找发现 此处将参数映射为String类型彻底正确,可是在映射到<select>中时 '%${name}%' 至关于调用了 sname.name  (即参数.name)app

解决方案以下 :测试

方案一 :   只需将  '%${name}%' 变为 '%${_parameter}%' 便可spa

方案二 :    将  '%${name}%' 变为 '%${value}%' 也可code

而后成功blog

相关文章
相关标签/搜索