Java EE 之 Hibernate异常总结【4】org.hibernate.exception.SQLGrammarException: could not execute statement
本质原因:配置的Java Bean,由Hibernate自动产生的SQL语句中有语法错误
原因如下:
情况1.存在字段名/表名与数据库关键字冲突
情况2.MySQL5.0以后与MySQL5.0以前事务引擎InnoDB配置微妙不同
//MySQL 5.0之后【engine = InnoDB】
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> //NySQL 5.0之前【type = InnoDB】
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
情况3:@Column的注解中的属性columnDefinition出问题
//正确
columnDefinition="int comment '房间可住人数上限'" //错误:原因:如果不加字段属性,hibernate反射时,会将comment视为字段名,将发生关键字冲突错误。
columnDefinition="comment '房间可住人数上限'"
情况4:数据类型转换错误
Java EE 之 Hibernate异常总结【4】org.hibernate.exception.SQLGrammarException: could not execute statement的更多相关文章
- 报错:org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n ...
- Java EE 之 Hibernate异常解决:org.hibernate.exception.SQLGrammarException: could not execute statement
本质原因:配置的Java Bean,由Hibernate自动产生的SQL语句中有语法错误 原因如下: 情况1.存在字段名/表名与数据库关键字冲突 情况2.MySQL5.0以后与MySQL5.0以前事务 ...
- [jnhs]hibernate只能创建一张/表不创建表com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'kaihu.t_client_info' doesn't exist和org.hibernate.exception.SQLGrammarException: could not execute statement
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'kaihu.t_client_info' doesn't exist ...
- HTTP Status 500 - Request processing failed; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement
1.什么操作出现:当我在项目中添加产品或者修改时,浏览器出现HTTP Status 500 - Request processing failed; nested exception is org.h ...
- 【hibernate】报错:org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement
报错如下: org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a ...
- ERROR: Field 'PostId' doesn't have a default value Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not execute statement
例子: Post p = new Post(); p.setPostId(3); p.setPostName("技术"); 在执行数据保持时提示session.save(p); 的 ...
- SpringBoot保存数据报错:could not execute statement; SQL [n/a]; constraint [PRIMARY];nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement
使用SpringBoot做JAVA开发时,用Repository.save();保存数据的时候遇到了报错: could not execute statement; SQL [n/a]; constr ...
- org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query
原因: 这个问题的解决方案很简单,主要是因为数据库中不存在相关的表或者列. org.springframework.dao.InvalidDataAccessApiUsageException: Pa ...
- org.hibernate.exception.SQLGrammarException: could not execute query
SSH项目中出现了 org.hibernate.exception.SQLGrammarException: could not execute query 错误,仔细检查后发现,是把createQu ...
随机推荐
- python自然语言处理函数库nltk从入门到精通
1. 关于Python安装的补充 若在ubuntu系统中同时安装了Python2和python3,则输入python或python2命令打开python2.x版本的控制台:输入python3命令打开p ...
- Django-website 程序案例系列-6 ajax案例
普通ajax案例: views.py def testajax(request): h = request.POST.get('hostname') #拿到ajax传来的值 i = request.P ...
- 【Linux】MGR部署脚本
脚本没有完善,现在只有上半部分的基础环境搭建 [准备条件] 1.三个节点的防火墙关闭 2.原有mysql卸载删除 3.文件夹名字: mgr 所有的源码包都放在mgr的文件夹下 4.文件位置: /roo ...
- ACG图片站\python爬虫\LAMP环境
最近突然对web很感兴趣,碰巧看到阿里云服务器学生价十块钱一个月,果断买了一个自己搭建了一个网站. 网址 这里 LAMP环境就搭建了好久,linux+apache2+mysql+php,都是开源的软件 ...
- MT【54】一道二次函数问题的几何意义
[Rather less, but better.]----卡尔·弗里德里希·高斯(1777-1855) (2016诸暨质检18)已知$f(x)=x^2-a|x-1|+b(a>0,b>-1 ...
- 分数模板(C++模板)
貌似没什么用...没有多少毒瘤题要输出分数吧... update:真的有,而且在NOIP模拟赛里出现了!写double的卡精度到怀疑人生! 可以套个兼容性比较好的高精度模板进来. #include&l ...
- android 面试准备基础题
1. 请描述下Activity的生命周期. 必调用的三个方法:onCreate() --> onStart() --> onResume(),用AAA表示 )父Activity启动子 ...
- [luogu2144][bzoj1002][FJOI2007]轮状病毒【高精度+斐波那契数列+基尔霍夫矩阵】
题目描述 轮状病毒有很多变种,所有轮状病毒的变种都是从一个轮状基产生的.一个N轮状基由圆环上N个不同的基原子和圆心处一个核原子构成的,2个原子之间的边表示这2个原子之间的信息通道.如下图所示 N轮状病 ...
- __AFO
博主已退役高考,博客基本就很少回复了 NOI2018的游记也没时间写了,以后补上吧[其实是自己懒] 嗯就这样,高三加油!
- Linux 常用命令——cat, tac, nl, more, less, head, tail, od
Drecik学习经验分享 转载请注明出处:http://blog.csdn.net/drecik__/article/details/8453584 1. cat 由第一行开始显示文件内容 2. ta ...