本质原因:配置的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. Delphi2007精简版加载Borland.Studio.Together.dll错误解决办法

    安装Delphi2007精简版,启动提示Borland.Studio.Together.dll加载错误,错误信息如下: Failed to load IDE add in 'C:\Program Fi ...

  2. python之tkinter使用-二级菜单

    # 菜单功能说明:二级菜单 import tkinter as tk from tkinter import messagebox root = tk.Tk() root.title('菜单选择') ...

  3. day9 集合基础命令

    集合的创建 s = set("hello") print(s) s = set({","alex","sb"}) print(s) ...

  4. 自学huawei之路-AC6005版本升级步骤

    返回自学Huawei之路 自学huawei之路-AC6005版本升级步骤 本文主要采用WEB网管界面升级,方便快捷,推荐使用此方法.     一.升级前检查 1.1 原AC/AP设备版本确认 disp ...

  5. 监控(1)-企业常用服务监控shell

    -----------------企业监控------------------------主动探测监控(“监控机”主动探测“被监控机”)HTTP服务器监控#!/bin/shLANG=C#被监控服务器. ...

  6. VirtualBox中slitaz系统不能联网

    首先,关于VirtualBox虚拟机中安装slitaz操作系统中,先不讲,现在假设电脑中已经装好了VirtualBox,并且已经装好了slitaz操作系统,一个轻量版的linux发行版本. 右上角我画 ...

  7. 【洛谷P1273】有线电视网

    题目大意:给定一棵 N 个节点的有根树,1 号节点为根节点,叶子节点有点权,每条边有边权,每经过一条边都减去该边权,每经过一个节点都加上该点权,求在保证权值和为非负数的前提下最多能经过多少个叶子节点. ...

  8. asp <----> vb(com,dll) <---> c 来回的调用,生命在于折腾

    最近想改进一个两年前写的小程序,原因是最近将运行在托管服务器上的asp程序迁移到阿里云主机上运行. 初次使用阿里云主机,买了一个配置较低的主机(1核,1G内存,年付:1500左右吧) 原来使用的托管的 ...

  9. 服务器内存占用不断的增加 & 任务管理器(PF使用率)不断的增加:关注句柄数

    最近一二个月以来,我发现服务器的内存占用正按着每天60M的速度增加. 一台windows 2003的服务器(2G内存),刚刚启起时占用内存:600M左右. 运行20天后,内存占用(PF使用):1.8G ...

  10. 2018 ACM 网络选拔赛 北京赛区

    A Saving Tang Monk II #include <bits/stdc++.h> using namespace std; ; struct node { int x,y,z, ...