mybatis查询符合条件的记录数时错误there is no getter for property named。。。

做分页查询时,查询符合条件的总记录数报错:

    java.lang.RuntimeException: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'nameText' in 'class java.lang.String'
    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'nameText' in 'class java.lang.String'
at 

mapper.xml的写法为:

    <select id="getUserCount" resultMap="ResultMapWithBLOBs">
    select count(*) 
    from user 
    <if test="nameText != null">
        where name like CONCAT(CONCAT('%', #{nameText}), '%')
    </if>
  </select>

原因:接口中返回值为int,所以这里的resultMap不可以是实体类,而应该是Integer,修改为:

<select id="getUserCount" parameterType="string" resultType="int">
    select count(*) 
    from user 
    <if test="nameText != null">
        where name like CONCAT(CONCAT('%', #{nameText}), '%')
    </if>
  </select>
int getUserCount(@Param("nameText") String nameText);
引用\[1\]:出现的错误信息是关于MyBatis的异常,具体是MyBatisSystemException和ReflectionException。错误信息中提到了一个属性名为'ew'的属性,在com.baomidou.mybatisplus.core.conditions.query.QueryWrapper类中找不到对应的getter方法。这个错误通常发生在使用MyBatis-Plus时,可能是因为在查询条件中使用了错误的属性名或者属性名拼写错误。解决这个问题的方法是检查代码中的查询条件,确保属性名的正确性。 问题:使用mybatis-plus时遇到there is no getter for property named 'ew'的错误,该如何解决? 回答: 出现这个错误通常是因为在使用MyBatis-Plus时,查询条件中使用了错误的属性名或者属性名拼写错误。解决这个问题的方法是检查代码中的查询条件,确保属性名的正确性。请检查您的代码中是否正确使用了属性名'ew',并且确保该属性在com.baomidou.mybatisplus.core.conditions.query.QueryWrapper类中存在对应的getter方法。如果属性名拼写正确且存在对应的getter方法,那么可能是其他原因导致的错误,请进一步检查您的代码和配置是否正确。 #### 引用[.reference_title] - *1* [Mybatis-plus查询问题 There is no getter for property named ‘ew’ in ‘class:query.QueryWrapper](https://blog.csdn.net/rows_com/article/details/120163341)[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^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值