There is no getter for property named 'province_code' in xxx pojo
阿新 • • 發佈:2022-05-24
總結
- 對映要對應,這裡我犯的錯誤是,動態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