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 ...
随机推荐
- 如何判断一条记录什么字段被修改了 [问题点数:40分,结帖人bluesukeke]
查询出来数据,在数据集编辑状态下,如何判断一条记录被修改了,哪些字段被修改了. 可用adoquery的Delta屬性...eg: ClientDataSet1.Delta... PS:POST前是準確 ...
- 百度/头条合作命中注定!中国新BAT要来了
据外媒报道,今日头条母公司字节跳动(ByteDace)将为中国互联网传统BAT的格局,带来一些新的活力.这家增速飞快的新闻.视频App“制造者”已经估值高达750亿美元,与三巨头之一的百度平起平坐,后 ...
- ELK--filebeat命令行参数解释
./filebeat 使用-c命令行上的标志设置要加载的配置文件,可以通过重复-c标志来指定多个配置文件, 可以使用覆盖个别设置-E <setting>=<value>.< ...
- FreeBSD ZFS
FreeBSD ZFS https://www.cnblogs.com/hadex/p/6068476.html 参考資料 http://docs.oracle.com/cd/E37934_01/ht ...
- 【Luogu4931】情侣?给我烧了! 加强版(组合计数)
[Luogu4931]情侣?给我烧了! 加强版(组合计数) 题面 洛谷 题解 戳这里 忽然发现我自己推的方法是做这题的,也许后面写的那个才是做原题的QwQ. #include<iostream& ...
- BZOJ3235 [Ahoi2013]好方的蛇 【单调栈 + dp】
题目链接 BZOJ3235 题解 求出每个点为顶点,分别求出左上,左下,右上,右下的矩形的个数\(g[i][j]\) 并预处理出\(f[i][j]\)表示点\((i,j)\)到四个角的矩形内合法矩形个 ...
- Android: View换切后,无法正常设置焦点或切换后TextView的虚拟键盘不弹出
边学.边测试,花了三天时间完工一个小应用. 遇到很多问题,但最终还是解决了. 我的手机是Android2.2版,所以我也在是2.2版环境下学习,开发. 1. 在同一个Activity中的不同View( ...
- redis 一主二从三哨兵
总体部署 一主二从三哨兵 ip地址分配分别为 主 127.0.0.1:6379 从 127.0.0.1:6389 从 127.0.0.1:6399 哨兵 127.0.0.1:26379 哨兵 127. ...
- SQL Server 日期函数大全
一.统计语句 1.--统计当前[>当天00点以后的数据] SELECT * FROM 表 WHERE CONVERT(Nvarchar, dateandtime, 111) = CONVERT( ...
- SSD详解
This results in a significant improvement in speed for high-accuracy detection(59 FPS with mAP 74.3% ...