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

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日