本质原因:配置的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. Essential Phone PH1官方刷机方法

    Essential Phone官方有两种包 一种是ota包,即sideload线刷使用的包.但此刷机方法只能ota升级,不能降级. 另一种是Images包,即fastboot线刷使用的包.这种方法可以 ...

  2. BZOJ4832[Lydsy1704月赛]抵制克苏恩——期望DP

    题目描述 小Q同学现在沉迷炉石传说不能自拔.他发现一张名为克苏恩的牌很不公平.如果你不玩炉石传说,不必担心,小Q 同学会告诉你所有相关的细节.炉石传说是这样的一个游戏,每个玩家拥有一个 30 点血量的 ...

  3. vmware错误汇总

    [问题来源] 因为虚拟机过大,所以直接在本地磁盘直接复制,启动的时候,换好IP重新启动网卡报错. device eth0 does not seem to be present.. ifconfig查 ...

  4. UOJ33 [UR #2] 树上GCD 【点分治】【容斥原理】【分块】

    题目分析: 树上点对问题首先想到点分治.假设我们进行了点分治并递归地解决了子问题.现在我们合并问题. 我们需要找到所有经过当前重心$ c $的子树路径.第一种情况是LCA为当前重心$ c $.考虑以$ ...

  5. Sabotage UVA - 10480 (输出割边)

    题意:....emm...就是一个最小割最大流,.,...用dinic跑一遍.. 然后让你输出割边,就是 u为能从起点到达的点,  v为不能从起点到达的点 最后在残余路径中用dfs跑一遍  能到达的路 ...

  6. 向git添加和提交文件

    状态 git status 可以知道有哪些文件被修改,哪些文件待提交 当前无待提交文件 分区 三个分区:工作区,缓存区,版本库 三个分区之间的联系: 工作区 >> git add > ...

  7. php语言基础语法与编程工具推荐

    php脚本语言,需要在服务器端执行,用浏览器返回HTML结果.在PHP中所有的语法都是如此,用户端是无法修改的,只有浏览权限. 一.php基础语法之输出方法 1.PHP中所有的脚本,可以放在文件中的任 ...

  8. 洛谷 P2158 [SDOI2008]仪仗队 解题报告

    P2158 [SDOI2008]仪仗队 题目描述 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线 ...

  9. bzoj1345 序列问题

    题意: 给你一个序列,长度为n.你需要进行n - 1次操作,每次合并两个相邻的数,代价是max,合并后成为max,求最小代价. n <= 1e6 解: 有个显然的做法是nlogn的,显然不行.. ...

  10. 二分查找、two points、排序

    二分查找 1.查找某元素.循环条件 low <= high,最终结果位mid, 如果查询失败则返回-1. int binSearch(int num[], int low, int high, ...