本质原因:配置的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的更多相关文章

  1. 报错: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 ...

  2. Java EE 之 Hibernate异常解决:org.hibernate.exception.SQLGrammarException: could not execute statement

    本质原因:配置的Java Bean,由Hibernate自动产生的SQL语句中有语法错误 原因如下: 情况1.存在字段名/表名与数据库关键字冲突 情况2.MySQL5.0以后与MySQL5.0以前事务 ...

  3. [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 ...

  4. 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 ...

  5. 【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 ...

  6. 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); 的 ...

  7. 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 ...

  8. org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.SQLGrammarException: could not execute query

    原因: 这个问题的解决方案很简单,主要是因为数据库中不存在相关的表或者列. org.springframework.dao.InvalidDataAccessApiUsageException: Pa ...

  9. org.hibernate.exception.SQLGrammarException: could not execute query

    SSH项目中出现了 org.hibernate.exception.SQLGrammarException: could not execute query 错误,仔细检查后发现,是把createQu ...

随机推荐

  1. BBS论坛项目

    一.表结构设计: 1.帖子: class Article(models.Model): title = models.CharField(max_length=255,unique=True) cat ...

  2. 快乐的Lambda表达式(二)

    转载:http://www.cnblogs.com/jesse2013/p/happylambda-part2.html 快乐的Lambda表达式 上一篇 背后的故事之 - 快乐的Lambda表达式( ...

  3. day9 函数练习题

    写代码,接受n个数字,求这些数字的和 def sum_func(*args): total = 0 for i in args: total+=i return total print(sum_fun ...

  4. MT【37】二次函数与整系数有关的题

    解析: 评:两根式是不错的考虑方向,一方面二次函数两根式之前有相应的经验,另一方面这里$\sqrt{\frac{b^2}{4}-c}$正好和两个根有关系.

  5. KMP模板(KMP)

    放一个模板在这里搞事情...... 学KMP的话找SYCstudio吧(博客链接) 代码(多组数据,\(O(n)\)求一个串是否在另一个串里出现过) #include<cstdio> #d ...

  6. LOJ #6270. 数据结构板子题 (离线+树状数组)

    题意 有 \(n\) 个区间,第 \(i\) 个区间是 \([l_i,r_i]\) ,它的长度是 \(r_i-l_i\) . 有 \(q\) 个询问,每个询问给定 \(L,R,K\) ,询问被 \([ ...

  7. 08 Zabbix Item类型之Zabbix agent类型

    点击返回:自学Zabbix4.0之路 点击返回:自学zabbix集锦 08 Zabbix Item类型之Zabbix agent类型 Zabbix agent类型的item是使用部署在服务器端的age ...

  8. 【BZOJ2424】[HAOI2010]订货(费用流)

    [BZOJ2424][HAOI2010]订货(费用流) 题面 BZOJ 洛谷 题解 傻逼费用流吧... 一开始理解错意思了,仓库大小为\(m\)的含义是留到下个月最多为\(m\),而不是任意时刻的容量 ...

  9. 【转】学习MOS管技术知识,这篇文章就够了!

    MOS管学名是场效应管,是金属-氧化物-半导体型场效应管,属于绝缘栅型.本文就结构构造.特点.实用电路等几个方面用工程师的话简单描述. 其结构示意图: 解释1:沟道 上面图中,下边的p型中间一个窄长条 ...

  10. C# ADO.NET与面向对象

    软件开发的三层:界面层,业务逻辑层,数据访问层: 数据访问层:项目添加App_Code文件夹: 实体类:根据数据库表结构,类名和数据库表名一致: 每个成员变量要与数据库表的列相对应,对象正好可以列为一 ...