错误异常: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. Struts 2(七):国际化

    基于Struts 2的Web应用国际化开发非常简单,其中Struts 2的国际化包括如下几部分:校验提示信息国际化.类型转换提示信息国际化.Action信息国际化以及JSP页面国际化. 第一节 JSP ...

  2. Appium+python 自动发送邮件(2)(转)

    (原文:https://www.cnblogs.com/fancy0158/p/10056418.html) 移动端执行完测试case之后,通过邮件自动发送测试报告.大体流程如下: 1.通过unitt ...

  3. Linux☞权限数字表示法

    权限数字表示法: 1.Linux有三种访问权限: a.可读:r(Read) b.可写:w(Write) c.可执行:x(eXcute) 2.简单说说如何去看该文件的访问权限呢?一般我们执行命令,查看目 ...

  4. Docker运行简单的Demo

    打开cmd.exe 输入docker run hello-world,本机没有这个images实例,将会从官方下载下载 运行一个简单的web实例,例如输入: docker run --name asp ...

  5. hive的内置函数和自定义函数

    一.内置函数 1.一般常用函数 .取整函数 round() 当传入第二个参数则为精度 bround() 银行家舍入法:为5时,前一位为偶则舍,奇则进. .向下取整 floor() .向上取整 ceil ...

  6. .net core 2.1.3可能引发Could not load file or assembly XXXXX的错误

    参考文档: https://github.com/aspnet/Home/issues/3503 写在前面 感觉自己现在干的活离开发越来越远了啊,不过也很好,每天能学到不少东西,中文的,英文的,永远也 ...

  7. PytorchZerotoAll学习笔记(三)--自动求导

    Pytorch给我们提供了自动求导的函数,不用再自己再推导计算梯度的公式了 虽然有了自动求导的函数,但是这里我想给大家浅析一下:深度学习中的一个很重要的反向传播 references:https:// ...

  8. eBay推Winit海外仓 鼓励卖家拓展北美市场

    [亿邦动力网讯]2月11日消息,日前,跨境电商平台eBay与外贸电商服务商万邑通(Winit)合作,针对平台卖家推出了Winit美国海外仓,鼓励卖家拓展北美市场. 亿邦动力网获悉,Winit美国海外仓 ...

  9. Python 数据图表工具的比较

    Python 的科学栈相当成熟,各种应用场景都有相关的模块,包括机器学习和数据分析.数据可视化是发现数据和展示结果的重要一环,只不过过去以来,相对于 R 这样的工具,发展还是落后一些. 幸运的是,过去 ...

  10. java不用任何已有方法完全自写的去重法

    package aa; class InsertSort{ private long[] a; private int nElems; //构造方法 public InsertSort(int max ...