**There is no getter for property named '**' in 'class ***'?问题:**

*在mapper.xml中写sql语句错误:更新多个字段时需要判断,加入
<if></if>
语句<if test="courseId !=null">
course_id=#{courseId}
</if> ,

这样来用java语法拼接到sql语句中;要注意sql语句中不能用!=null来判断非空,要用is not null;
test="courseId 1=null"为java语法,不要写成了test="course_id != null".
另外, 更新多个字段使用<set></set>,将要更新的字段以及判断语句包裹进去,在外层加上where 对应的条件*


<!--修改课程信息-->
    <update id="updateCourseByCourseId" parameterType="Course">
        update course
      <set>
        <if test="**courseName**  != null ">
             course_name  = #{**courseName**},
        </if>
        <if test="teacherId != null ">
             teacher_id   = #{teacherId},
        </if>
        <if test="courseTime != null ">
            course_time  = #{courseTime},
        </if>
        <if test="courseRoom != null ">
             course_room  = #{courseRoom},
        </if>
        <if test="courseWeek != null ">
             course_week  = #{courseWeek},
        </if>
        <if test="courseType != null ">
             course_type  = #{courseType},
        </if>
        <if test="collegeId != null ">
             college_id   = #{collegeId},
        </if>
        <if test="courseScore != null ">
             course_score = #{courseScore},
        </if>
      </set>
        where course_id =#{courseId}
    </update>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值