【springboot】 ReflectionException: There is no getter for property named ‘list‘ in ‘class XXX

MyBatis映射异常:

上层请求的参数与实体类属性不对应,这里传入了一个给stutus传入了一个List,而实体类中是String类型,类型不匹配。

异常信息:

ERROR c.k.f.w.e.GlobalExceptionHandler - [handleRuntimeException,69] - 请求地址'/system/XXX',发生未知异常.
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'list' in 'class com.ktg.quartz.domain.XXXX'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441)
at com.sun.proxy.$Proxy107.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224)
at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)
at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:145)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86)
at com.sun.proxy.$Proxy168.selectSysTodoList(Unknown Source)
at com.ktg.quartz.service.impl.SysTodoServiceImpl.selectSysTodoList(SysTodoServiceImpl.java:44)
at com.ktg.quartz.controller.SysTodoController.list(SysTodoController.java:48)
at com.ktg.quartz.controller.SysTodoController$$FastClassBySpringCGLIB$$72e747f3.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:783)

我是想在sql中传入实体类作为查询条件,同时传入一个List带多个状态通过foreach一起查询出来

<select id="selectSysTodoList" parameterType="SysTodo" resultMap="SysTodoResult">
    <include refid="selectSysTodoVo"/>
    <where>  
        <if test="todoTitle != null  and todoTitle != ''"> and todo_title = #{todoTitle}</if>
        <if test="todoType != null  and todoType != ''"> and todo_type = #{todoType}</if>
        <if test="todoContent != null  and todoContent != ''"> and todo_content = #{todoContent}</if>
        <if test="todoObject != null "> and todo_object = #{todoObject}</if>
        <if test="status != null  and status != ''">
        and status in
            <foreach item="status" collection="list" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        <if test="expire != null "> and expire = #{expire}</if>
        <if test="workshopId != null "> and workshop_id = #{workshopId}</if>
        <if test="deptId != null "> and dept_id = #{deptId}</if>
    </where>
</select>

解决起来比较简单,上层直接传一个String过来就行 this.params.status = "0,1,3",sql这边去掉 标签,不过不能直接改成and status in #{status},会出现格式问题,在msqyl中使用FIND_IN_SET(status, #{status})就OK!

<if test="todoObject != null "> and todo_object = #{todoObject}</if>
<if test="status != null  and status != ''"> and FIND_IN_SET(status,#{status})</if>
<if test="expire != null "> and expire = #{expire}</if>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

从头学习的老廖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值