There is no getter for property named 'province_code' in xxx pojo

总结

- 映射要对应,这里我犯的错误是,动态sql插入没映射正确

<insert id="insertSelective" >
    insert into category_info
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="provinceCode != null" >
        province_code,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
      <if test="updateTime != null" >
        update_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      </if>
      <if test="provinceCode != null" >
        #{province_code,jdbcType=TINYINT},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="updateTime != null" >
        #{updateTime,jdbcType=TIMESTAMP},
      </if>
    </trim>
  </insert>

- 其中 parameterType = 'xxx.pojo'在dao层有@param("")注解时可以不用写,该注解在有多个参数时需要加上,(实体时可以不用加,但需要在xml中添加parameterType参数)

- 这里报错的原因是 value对应的是`provinceCode`而不是'province_code',在报错的时候已经提示了 实体中找不到province_code

 

posted @ 2022-05-24 15:37  白玉神驹  阅读(80)  评论(0)    收藏  举报