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

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

在确定该字段在entity中添加了get set方法之后,通常情况报这个错是因为mapper.xml中名称没有保持一致导致的。


<!-- 结果Map -->
	<resultMap id="BaseResultMap" type="com.business.monitor.BaseEquipmentEntity">
		<result property="relationId" jdbcType="INTEGER" column="f_relation_id"/>
		<result property="equipmentId" jdbcType="VARCHAR" column="f_equipment_id"/>
		<result property="baseId" jdbcType="VARCHAR" column="f_base_id"/>
		<result property="host" jdbcType="VARCHAR" column="f_host"/>
		<result property="port" jdbcType="INTEGER" column="f_port"/>
		<result property="username" jdbcType="VARCHAR" column="f_username"/>
		<result property="password" jdbcType="VARCHAR" column="f_password"/>
		<result property="name" jdbcType="VARCHAR" column="f_name"/>
		<result property="remark" jdbcType="VARCHAR" column="f_remark"/>
		<result property="enterpriseId" jdbcType="VARCHAR" column="f_enterprise_id"/>
	</resultMap>

<!-- 分页查询 -->
<select id="queryByPage" parameterType="com.common.vo.ListVo.ListReqVO"
		resultMap="BaseResultMap">
		SELECT
                c.f_enterprise_id,
               c.f_relation_id,
		c.f_base_id,
		c.f_host,
		c.f_equipment_id,
		d.f_name,
		d.f_remark,
		FROM t_base_equipment AS c INNER JOIN t_internet_things_equipment AS d
		ON c.f_equipment_id = d.f_equipment_id
	<where>
	1=1
	<if test="whereCondition!=null">
	<if test="whereCondition.enterpriseId!=null">AND c.f_enterprise_id = #{whereCondition.enterpriseId,jdbcType=VARCHAR}</if>
	<if test="whereCondition.relationId!=null">AND f_relation_id = #{whereCondition.relationId,jdbcType=INTEGER}</if>
	<if test="whereCondition.host!=null and whereCondition.host!=''">AND f_host like CONCAT('%',#{whereCondition.host,jdbcType=VARCHAR},'%')</if>
	<if test="whereCondition.name!=null and whereCondition.name!=''">AND d.f_name like CONCAT('%',#{whereCondition.name,jdbcType=VARCHAR},'%')</if>
	</if>
	</where>
</select>

其中

<result property="enterpriseId" jdbcType="VARCHAR" column="f_enterprise_id"/>

 <if test="whereCondition.enterpriseId!=null">AND c.f_enterprise_id = #{whereCondition.enterpriseId,jdbcType=VARCHAR}</if>


//property的字段名称一致,column为数据库中字段名要一致,即例子中红色位置与红色一致,蓝色位置与蓝色一致。

//这是我在使用中遇到的问题及解决,当时名称未保持一致,出现如题的报错情况,将名称更正一致后,问题解决。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
从给出的引用中可以看出,问题出现在Mybatis的映射文件中。报错信息"There is no getter for property named 'categoryId' in 'class com.sky.dto.SetmealPageQueryDTO'"表明在'com.sky.dto.SetmealPageQueryDTO'类中找不到名为'categoryId'的属性的getter方法。这意味着在映射文件中使用了错误的字段名'#{categoryId}'。正确的字段应该是'#{categryId}',即字段名应为'categryId'。所以需要将映射文件中的'#{categoryId}'修改为'#{categryId}'即可解决此问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [There is no getter for property named ‘NULL‘ in ‘class com.xxxx](https://blog.csdn.net/qq1610741617/article/details/125851429)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [Mybatis单个参数的if判断报异常There is no getter for property named 'xxx' in 'class java.lang.Integer...](https://download.csdn.net/download/weixin_38672962/12753379)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值