错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'

映射器类(Mapper interface)

public interface NarCodeService {

    public NarCode getNarCode(String id);

}

Xml映射文件配置(部分)

<select id="getNarCode" parameterType="java.lang.String"
resultType="narCode">
select
<include refid="Base_Column_List"></include>
from nar_code
<where>
<if test="id != null">
id=#{id,jdbcType=VARCHAR}
</if>
</where>
</select>

这是Mybatis Xml映射文件配置,当我执行这个映射select语句时报错:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'

解决办法有两种:

1.去掉sql语句的if标签限制

<if test="id != null">
id=#{id,jdbcType=VARCHAR}
</if>
改为:
id=#{id,jdbcType=VARCHAR} 原因:我自己猜测加上if标签时,id属性没有包含在数据类型为String id对象中。
如果去掉if标签时直接使用这个数据类型为String id对象 2.将parameterType="java.lang.String"参数改为传一个自定义实体对象或者HashMap来封装这个id参数
原因:可以在自定义实体对象或者HashMap中找到这个id属性
 

Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'的更多相关文章

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

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

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

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

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

  6. 已解决: 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 ...

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

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

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

随机推荐

  1. kali2.0下JAVA安装

    参考网址:http://www.blackmoreops.com/2013/10/26/how-to-install-java-jdk-in-kali-linux/ 1.下载javase,http:/ ...

  2. angular promise $q 异步调用

    Angular异步调用 Promise和$q的用法 背景 首先说明一下promise异步调用出现的背景: javascript语言是一种单线程模式,就是说一次只能够执行一个任务,如果有多个任务的话就必 ...

  3. Ajax在Django中的应用

    一.什么是Ajax AJAX(Asynchronous Javascript And XML)翻译成中文就是“异步Javascript和XML”.即使用Javascript语言与服务器进行异步交互,传 ...

  4. VBA_常用VBA代码

    '批量替换字符 Sub Test() Dim i As Integer ).Value = "已激活" Then Cells(i, ).Value = "Active&q ...

  5. python-面向对象-内置方法补充

    __del__item系列 __getitem__ __setitem__ __delitem____hash____eq__ 构造方法 申请一个空间析构方法 释放一个空间之前执行某对象借用了操作系统 ...

  6. 03-运行第一个docker容器

    环境选择 容器需要管理工具.runtime 和操作系统,我们的选择如下: 1.管理工具 - Docker Engine因为 Docker 最流行使用最广泛. 2.runtime - runc Dock ...

  7. php文章tag标签的增删

    <?php session_start();   if($_POST){           $_SESSION['old']=array('one','two','three','four', ...

  8. php 操作 oracle lob 数据2

    CREATE SEQUENCE mylobs_id_seq    NOMINVALUE    NOMAXVALUE    NOCYCLE    CACHE 20    NOORDERINCREMENT ...

  9. 使用Photon引擎进行unity网络游戏开发(三)——网络游戏大厅及房间

    使用Photon引擎进行unity网络游戏开发(三)--网络游戏大厅及房间 Photon PUN Unity 网络游戏开发 连接到Photon ConnectUsingSettings 设置你的客户端 ...

  10. 在进行分布式框架搭建的过程中,出现问题advised by org.springframework.transaction.interceptor.TransactionInterceptor.invoke(org.aopalliance.intercept.MethodInvocation)?

    今天在进行宜立方商城,进行文件配置的时间,遇到如下的问题,问题是:advised by org.springframework.transaction.interceptor.TransactionI ...