There is no getter for property named 'xxx' in 'class java.lang.String

报错信息:

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘investTime‘ in ‘class java.lang.String‘
    at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:76)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)
    at com.sun.proxy.$Proxy30.selectOne(Unknown Source)
    at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:165)
    at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:69)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
    at com.sun.proxy.$Proxy36.mokuUserTotalAmount(Unknown Source)

错误写法:

<if test="investDate!=null and investDate!=‘‘">
    AND invest.addtime LIKE CONCAT(‘%‘,#{investDate},‘%‘)
</if>

正确写法:

<if test="_parameter!=null and _parameter!=‘‘">
      AND invest.addtime LIKE CONCAT(‘%‘,#{_parameter},‘%‘)
</if>

总结:

如果不用if test来判断的话,不管哪种写法都不会报错!建议都用_parameter来写,多参数用Map或者封装一个bean来做参数

There is no getter for property named 'xxx' in 'class java.lang.String

时间: 2024-10-10 03:21:56

There is no getter for property named 'xxx' in 'class java.lang.String的相关文章

Mybatis中传参包There is no getter for property named &#39;XXX&#39; in &#39;class java.lang.String&#39;

一.发现问题 <select id="queryStudentByNum" resultType="student" parameterType="string"> select num,name,phone from student <where> <if test = " num!=null and num!='' "> AND num = #{num} </if> <

There is no getter for property named xxx&#39; in &#39;class java.lang.xxx&#39;

在xxxMapper.xml我们使用sql片段来提高sql代码的复用性,当时新手传入参数时常常出现这样的错误: There is no getter for property named xxx' in 'class java.lang.xxx' ①出现的原因:我们实体类中有getter方法,为啥mybatis无法识别呢,原来Mybatis默认采用ONGL解析参数,所以会自动采用对象树形式来取java.lang.xxx.xxx值,所以引起报错. ②解决方法: 1)将传入参数改为_paramete

关于mybtis 使用过程中发生There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39; 错误

今天在修改一个关于mybtis语句时,偶然发现的一个错误  There is no getter for property named 'id' in class 'java.lang.String', 纠结了许久,终于明白了为什么. 原因:Mybatis默认采用ONGL解析参数,所以会自动采用对象树的形式取 string.xxx 值,如果没在在方法中定义,则会抛异常报错.当然也不是所有的版本会有这个问题,我的项目用的版本比较老. 有两种解决方案: 方案一: 将对应的参数用 _parameter

There is no getter for property named &#39;userId&#39; in &#39;class java.lang.String&#39;

[ERROR] 2017-01-18 04:37:06:231 cn.dataenergy.common.CenterHandlerExceptionResolver (CenterHandlerExceptionResolver.java:44) - 统一捕获异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Th

org.apache.ibatis.reflection.ReflectionException: There is no getter for property named &#39;parentId&#39; in &#39;class java.lang.String&#39;

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String' at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333) at org.apache.ibatis.reflection.Meta

Mybatis问题:There is no getter for property named &#39;unitId&#39; in &#39;class java.lang.String&#39;

Mybatis遇到的问题 问题: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'unitId' in 'class java.lang.String' at org.mybatis.spring.MyBatisExceptionTransla

MyBatis3: There is no getter for property named &#39;code&#39; in &#39;class java.lang.String&#39;

mybatis3  : mysql文如下,传入参数为string类型时‘preCode’,运行报错为:There is no getter for property named 'preCode' in 'class java.lang.String 执行sql: mapper.xml文件: <select id="getMaxCode" parameterType="string" resultType="string"> sele

mybaits错误解决:There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39;(转)

在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter来代替参数名. 正确的写法: [html] view plain <span style="font-size:18px;">    <!-- 用于查询运单号是否存在 --> <select id="isCargoBillNoExist" resultType="java.lang.Integer&quo

mybaits错误解决:There is no getter for property named &#39;id&#39; in class &#39;java.lang.String&#39;

在使用mybaitis传参数的时候,如果仅传入一个类型为String的参数,那么在 xml文件中应该使用_parameter 来代替参数名. 正确的写法: [html] view plaincopyprint? <span style="font-size:18px;">    <!-- 用于查询运单号是否存在 --> <select id="isCargoBillNoExist" resultType="java.lang.