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 SQL Server下载
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件
  • ¥15 不同系统编译兼容问题
  • ¥100 三相直流充电模块对数字电源芯片在物理上它必须具备哪些功能和性能?
  • ¥30 数字电源对DSP芯片的具体要求