今天在写需求的时候发现mapper的xml映射不上,但是线上环境因为各种原因无法变动,所以只能在mapper层用注解的形式写sql 在写到修改sql的时候可是难住我了
在经历重重尝试之后 最后动态修改的sql被我研究出来了
废话不多说 直接上代码
@Update({"<script>",
"update down_task",
"<set>",
"<if test='ocId !=null'>",
"oc_id=#{ocId,jdbcType=VARCHAR},",
"</if>",
"<if test='createBy !=null'>",
"create_by=#{createBy,jdbcType=VARCHAR},",
"</if>",
"<if test='createTime !=null'>",
"create_time=#{createTime,jdbcType=TIMESTAMP},",
"</if>",
"<if test='updateBy !=null'>",
"update_by=#{updateBy,jdbcType=VARCHAR},",
"</if>",
"<if test='updateTime !=null'>",
"update_time=#{updateTime,jdbcType=TIMESTAMP},",
"</if>",
"<if test='status !=null'>",
"status=#{status,jdbcType=TINYINT},",
"</if>",
"<if test='isDelete !=null'>",
"is_delete=#{isDelete,jdbcType=TINYINT},",
"</if>",
"<if test='remark !=null'>",
"remark=#{remark,jdbcType=VARCHAR},",
"</if>",
"</set>",
"where id=#{id,jdbcType=INTEGER}",
"</script>"})
int updateById(DownTask task);