项目场景:

项目使用了mybatis-plus进行数据库操作


问题描述

例如:后端无法插入数据,控制台输出如下信息

org.springframework.jdbc.BadSqlGrammarException:
### Error updating database.  Cause: java.sql.SQLSyntaxErrorException: Unknown column 'experience_openness' in 'field list'
### The error may exist in com/woniu/mapper/PersonalityHandledMapper.java (best guess)
### The error may involve com.woniu.mapper.PersonalityHandledMapper.insert-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO personality_handled  ( extraversion, agreeableness, seriousness, neuroticism, experience_openness )  VALUES  ( ?, ?, ?, ?, ? )
### Cause: java.sql.SQLSyntaxErrorException: Unknown column 'experience_openness' in 'field list'
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Unknown column 'experience_openness' in 'field list'at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:74)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64)at com.sun.proxy.$Proxy106.update(Unknown Source)at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:50)at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.apache.ibatis.plugin.Invocation.proceed(Invocation.java:49)at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:106)at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62)at com.sun.proxy.$Proxy105.update(Unknown Source)at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:194)at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:181)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427)... 81 more


原因分析:

数据库中的字段使用了小驼峰命名法,因此在JAVA代码中也使用了小驼峰命名法,但是没因为mybatis-plus会自动识别小驼峰命名法的属性在数据库中的字段名是experienceo_openness的形式因此导致了错误。


解决方案:

数据库中的字段名改为experienceo_openness的形式或者JAVA的属性名改成全小写。

Error updating database. Cause: java.sql.SQLSyntaxErrorException: Unknown column ‘experience_openne相关推荐

  1. Cause: java.sql.SQLSyntaxErrorException: Unknown column 'xxxxx' in 'fiel

    Unknown column 'xxxxx' in 'fiel 今天又遇到一个问题,找了半天没有找到,头大,心累,身体难受,蓝瘦香菇!!!!! Error querying database. Cau ...

  2. rror updating database. Cause: java.sql.SQLSyntaxErrorException解决方案

    错误描述: ### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in you ...

  3. ### Error updating database. Cause: java.sql.SQLException: Incorrect integer value: ‘**‘ for column

    类型 异常报告消息 Request processing failed; nested exception is org.apache.ibatis.exceptions.PersistenceExc ...

  4. Error querying database. Cause: java.sql.SQLSyntaxErrorException: ORA-00911: 无效字符

    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is ...

  5. Uncaught (in promise)Error: ### Error updating database. Cause :java.sql.SQLException:

    Uncaught (in promise)Error: ### Error updating database.    Cause :java.sql.SQLException:   Field 'X ...

  6. 解决及分析:MySQL的 Error updating database. Cause: java.sql.SQLException: You can’t specify target table

    一.项目从Oracle迁移到MySQL时,报错:Error updating database. Cause: java.sql.SQLException: You can't specify tar ...

  7. 运行mybatis时显示报错:Error updating database. Cause: java.sql.SQLException: Error setting driver on

    在运行mybatis测试类的时候,结果报错; Error updating database. Cause: java.sql.SQLException: Error setting driver o ...

  8. Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Cannot add or up

    报错描述: Error updating database. Cause: java.sql.SQLIntegrityConstraintViolationException: Cannot add ...

  9. java.sql.SQLSyntaxErrorException Unknown column····

    今天在连接数据库时,遇到了这样一个问题 java.sql.SQLSyntaxErrorException: Unknown column 'name' in 'field list'看上去好像是nam ...

最新文章

  1. JSP 客户端请求概述
  2. 是什么让深度学习再次崛起并超越人类?
  3. 前端基于gulp后端基于freemarker的工作流程总结
  4. Ogre 编辑器二(用Ogre的地形组件加载天龙八部地形)
  5. iOS 延迟1.5s 执行方法
  6. 海量数据处理:两个大文件中的相同记录
  7. java获取行号_java – 如何获取一个方法的行号?
  8. 增量式pid_PID 基础知识汇总
  9. python中left是什么意思_Python left
  10. 微信 php收藏功能实现,关于微信小程序收藏功能的实现
  11. LFFD 再升级!新增行人和人头检测模型,还有了优化的C++实现
  12. CV学习笔记-浅述CV方向
  13. 来不及说再见,Kobe
  14. 看图计算机械加工工时,急求机械加工工艺编制和工时定额制定与核算软件!!!...
  15. CAD图纸被加密了,如何打开?
  16. ZUFE 2017院赛 - Problem M: 图样图森破(树状数组)
  17. 【opencv】图片拼接
  18. 中华瑰宝之山西人的面食
  19. 最常见的开源游戏引擎
  20. 虚拟机安装Ubuntu 22.4

热门文章

  1. 【Web前端HTML+CSS基础——常规流和浮动(猫眼电影项目实战)】
  2. esp32-pico-d4开发环境配置
  3. 小红书10万粉算大号么?快速涨粉实用技巧
  4. 如何删除word的分节、分页?
  5. 初等模型---划艇比赛的成绩
  6. 10.Windchill -- 客制化生命周期状态和角色
  7. tic/toc/cputime测试时间
  8. 【Python】自动去除图片背景——Python抠图,就是这么轻松
  9. linux编译mt7601,WDMyCloud编译USB网卡MT7601U驱动(小米,小度,360WiFi)
  10. [软件自动修复领域] 前沿论文阅读(2019年8月12日)