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

在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)将传入参数改为_parameter这样就可以了,例如: 

<sql id="whereCadtion">
<if test="_parameter">
and AREA_ID=#{_parameter}
</if>
</sql>
<sql id="Base_Column_List">
ID,DEPT_NAME,USER_NAME,JOB_NAME,DAYS,ENTRY_CORE,AREA_ID,AREA_NAME
</sql>
<select id="findAllCarEntry" parameterType="int" resultMap="resultMap">
select <include refid="Base_Column_List"/> from vie_car_entry_top
<where>
<include refid="whereCadtion"/>
</where>
</select>

2)将接口参数名说明参数值。例如:

public List methodName(@Param(value="tj") String tj);

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

时间: 2024-10-19 00:44:57

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

关于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

MyBatis查询传一个参数时报错:There is no getter for property named &#39;sleevetype&#39; in &#39;class java.lang.Integer

用MyBatis进行查询,传入参数只有一个时(非Map)如int,报错 There is no getter for property named 'sleevetype' in 'class java.lang.Integer 原因在于测试条件写法有误, <if test="sleevetype==0"><!-- 专属 --> exclusive=1 </if> <if test="sleevetype!=0">&l

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

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

mapper.xml: <delete id="deleteByPurchaseAppyId" parameterType="Long"> <if test="purchaseApplyId != null"> delete from <include refid="t_purchaseApplyItem"/> where purchase_apply_id = #{purchaseAppl

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.

mybatis 异常 There is no getter for property named &#39;bizId&#39; in &#39;class java.lang.Long&#39;

mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long' 当使用mybatis进行传参的时候,参数只有一个时会出现这种类似的错误. 解决: 1.接口定义出,指定参数名 2.在xml 中指定类型 mybatis 异常 There is no getter for property named 'bizId' in 'class java.lang.Long'