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 @   白玉神驹  阅读(66)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示