TimeCollectTime 2021-10-06 21:28 采纳率: 50%
浏览 12

Mybatis中<if test="id!=0">加上后报id在Integer里没有get方法,不加就没事

报错为:
org.apache.ibatis.exceptions.PersistenceException:

Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'

    <select id="findById" parameterType="int" resultType="user">
        <include refid="selectUser"/>
        <where>
            <if test="id!=0">
                and id=#{id}
            </if>
        </where>
    </select>
</mapper>

想问问为何
  • 写回答

1条回答 默认 最新

  • 大鹏cool Java领域优质创作者 2021-10-06 22:10
    关注

    Mapper 接口方法的参数上加上 @Param("id") 试试

    评论

报告相同问题?

问题事件

  • 创建了问题 10月6日

悬赏问题

  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题
  • ¥15 matlab有限元法求解梁带有若干弹簧质量系统的固有频率
  • ¥15 找一个网络防御专家,外包的
  • ¥100 能不能让两张不同的图片md5值一样,(有尝)
  • ¥15 informer代码训练自己的数据集,改参数怎么改
  • ¥15 请看一下,学校实验要求,我需要具体代码
  • ¥50 pc微信3.6.0.18不能登陆 有偿解决问题