jeffery_12 2017-09-22 07:02 采纳率: 0%
浏览 1003

mybatis框架,在前端页面实行修改功能时报错

错误如下文并附上mapper.xml中修改代码,不清楚哪里出了问题,先谢谢各位了
以下为报错信息: org.springframework.jdbc.BadSqlGrammarException:

Error updating database. Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where file_id = null' at line 3

The error may involve com.arvato.cms.file.dao.mappers.FileMapper.updateByPrimary-Inline

The error occurred while setting parameters

SQL: update cms_files where file_id = ?

Cause: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where file_id = null' at line 3

; bad SQL grammar []; nested exception is com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
near 'where file_id = null' at line 3

以下为功能xml代码:


update cms_files

<set >
  <if test="file_name != null" >
    file_name = #{file_name,jdbcType=VARCHAR},
  </if>
  <if test="file_type != null" >
    file_type = #{file_type,jdbcType=CHAR},
  </if>
  <if test="file_url != null" >
    file_url = #{file_url,jdbcType=VARCHAR},
  </if>
  <if test="file_remak != null" >
    file_remak = #{file_remak,jdbcType=VARCHAR},
  </if>
  <if test="file_state != null" >
    file_state = #{file_state,jdbcType=CHAR},
  </if>

</set>
where file_id = #{file_id,jdbcType=CHAR}

  • 写回答

8条回答 默认 最新

  • 一叶_知秋_ 2017-09-22 07:07
    关注

    在第三行 文件ID 为null ,where 没有加IF 非空判断 导致报错

    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置