ibatis 报错:There is no getter for property named 'device_no' in 'class.xxx

报错位置为 mapper.xml 文件,sql 带入的参数变量找不到:

    <update id="updateByDeviceNo" parameterType="CaseGpsInfo">
        update case_gps_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="deviceStatus != null  and deviceStatus != ''">device_status = #{deviceStatus},</if>
            <if test="deviceStatusMessage != null  and deviceStatusMessage != ''">device_status_message = #{deviceStatusMessage},</if>
            <if test="supplierName != null  and supplierName != ''">supplier_name = #{supplierName},</if>
        </trim>
        where device_no = #{device_no}
    </update>

因为属性名称通常都是驼峰格式,而数据库字段多为下划线。所以这里的 #{device_no} 明显不是 CaseGpsInfo 中的属性,而应该是 deviceNo

修改之后问题解决。