解决org.hibernate.exception.SQLGrammarException:could not insert

今天在使用hibernate搭建项目时碰到了这个错误,找了好半天没能发现错误的原因,

上网求助了一下

发现出现这个bug的原因是因为数据表使用了数据库的关键字(保留字)

然后检查了一下,发现字段名称都不是关键字,那问题出现在哪呢?

再次检查发现是数据表的名字使用了数据库的关键字order

很小的一个错误因为粗心浪费了很多时间,

原文地址:https://www.cnblogs.com/aihuadung/p/10202402.html

时间: 2024-08-29 20:37:00

解决org.hibernate.exception.SQLGrammarException:could not insert的相关文章

Java EE 之 Hibernate异常解决: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</proper

Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet

org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.springframework.orm.jpa.vendor.HibernateJpaDi

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update

org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update org.hibernate.exception.SQLGrammarException: Could not execute JDBC batch update,码迷,mamicode.com org.hibernate.exception.SQLGrammarException: Could not execute JDBC batc

Exception occurred during processing request: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet

今天在编码的时候遇到了 Exception occurred during processing request: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet这个问题,也是找了老半天不懂什么原因,后来找了好多论坛,总结了一下,只要出现了sql的问题,基本都是bean或者XXX.

org.hibernate.exception.SQLGrammarException: could not execute query 没有找到数据库

org.hibernate.exception.SQLGrammarException: could not execute query org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90) org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) org.hibernate.loader.Lo

org.hibernate.exception.SQLGrammarException: could not extract ResultSet

这个故障的原因比较多: 1.如数据库中的字段和类中的字段类型不一致: 2.数据库dialect不够具体 myeclispe自动生成的是  org.hibernate.dialect.SQLServerDialect 如果连接的是SQLSERVER 2008 则可以写成org.hibernate.dialect.SQLServer2008Dialect

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

// 打开会话 Session session = HibernateUtil.getSession(); // 开启事务 Transaction tx = null; Wine wine; try { tx = session.beginTransaction(); String sql = "SELECT * FROM wine WHERE W_ID >= (SELECT floor(RAND() * (SELECT MAX(W_ID) FROM wine))) ORDER BY W_

org.hibernate.exception.ConstraintViolationException: could not insert:

报错原由于xxx.hbm.xml文件里的主键类型设置有问题: 当我们的数据库表没实用自增长的int型id.而用的varchar就可能报上面的错误, 假设,主键的生成类型设置为identity或者native的时候底层数据库会自己主动生成一个long,short或者是int,假设ID设计的是用String,数据库就无法插入的,所以假设你的数据库的ID设计的是用String型的,最好是用assigned. 比如: <id name="userId" type="java.l

[转] Hibernate不能自动建表解决办法(hibernate.hbm2ddl.auto) (tables doesn&#39;t exist)

转自: http://blog.csdn.net/biangren/article/details/8010018 最近开始学Hibernate,看的是李刚的那本<轻量级java ee企业应用实战>.头一个hibernate程序,我原原本本的按照书上例子写下来,同时只是改动了些mysql的连接参数,并且在mysql中新建了一个hibernate数据库,仅此而已.然而预想不到的事情发生了……程序写好之后,运行,报错 Hibernate: insert into news_table (title