There is no getter for property named 'id' in 'class java.lang.Integer'问题解决办法

`Exception in thread “main” org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘id’ in ‘class java.lang.Integer’问题解决办法`
(1) 使用xml配置文件的方式
    将if块中的判断参数名字改为  “_parameter” ,无论传进来的是什么,一律写为 “_parameter”

example:

<select id="getStudent" parameterType="String" resultType="com.bx.pojo.Student">
        select id,name,nickName from Student
        <where>
            <if test="_parameter != null and '' != _parameter">
                id = #{id}
            </if>
        </where>
    </select>
(2)使用注解的方式
    ①使用<script></script>将select语句包起来,并且在接口类的方法中的参数列表中参数使用@Param(value="id")修饰
    example:
    @Select("<script> select id,name,nickname from student <where> <if test=\" id!=null and \'\' !=id \"> id = #{id} </if> </where> </script>")
    public List<Student> getStudent(@Param(value="id")int id);
②使用 selectProvide接口
example:接口类代码
@SelectProvider(method = "getStudent", type = SqlProvider.class)
public List<Student> getStudent(int id);
SqlProvider类代码:
public String getStudent(Integer id){
        String sql = "select id,name,nickName from student";
        if(id != null){
            sql = sql + " where id = " + id.intValue();
        }
        return sql;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值