There is no getter for property named 'insurance_id' in 'class studio.geek.entity.StudentInsurance'

There is no getter for property named 'insurance_id' in 'class studio.geek.entity.StudentInsurance'

这个异常提示,我想每个人都能看懂:在studio.geek.entity.StudentInsurance这个实体类里没有属性insurance_id的getter方法。

出现这个There is no getter for property named 'xxx' in 'class xxx'的异常,一般在提示的类里加上对应属性的getter方法就可以了(如果真的是因为在提示的类里缺少getter方法的话)。

但是我的程序故障不在这里,而是在映射文件里。

事实上当我看到是insurance_id属性缺少getter方法的时候,我就知道,绝对不是这个类里缺少insurance_id的getter方法,因为我的这个类里根本没有这个属性。而且我知道,这个insurance_id是数据表的字段,它对应的实体类的属性是insuranceId,所以我猜测可能是映射文件写错了。

找到映射文件:

    <select id="selectByPrimaryKey" parameterType="studio.geek.entity.StudentInsuranceKey" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM student_insurance
        WHERE student_id = #{studentId,jdbcType=CHAR}
        AND insurance_id = #{insurance_id,jdbcType=SMALLINT}
    </select>


如上面粗体标注的部分,果然写错了,insuranceId写成了insurance_id。将错误改掉之后,异常解决。

发布了10 篇原创文章 · 获赞 3 · 访问量 5456

猜你喜欢

转载自blog.csdn.net/AttleeTao/article/details/70738146