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 非空判断 导致报错

    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型