org.hibernate.exception.SQLGrammarException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • I've updated from Hibernate 4.1.7 to Hibernate 4.3. I'm using hsqldb 2.3.2 and I'm encountering an issue with a joined inheritance strategy and a DiscriminatorValue annotation. Hibernate appears to be generating invalid SQL (not quoting a referenced DiscriminatorValue in a query). Code that worked in 4.1.7: {code} criteria.add(Restrictions.eq("class", MyChildObject1.class)); {code} Now causes the following exception: {code} Hibernate: insert into MyBaseObject (id, DTYPE) values (default, 'one') Hibernate: insert into MyChildObject1 (id) values (?) Hibernate: insert into MyBaseObject (id, DTYPE) values (default, 'two') Hibernate: insert into MyChildObject2 (id) values (?) Hibernate: select this_.id as id2_0_0_, this_.DTYPE as DTYPE1_0_0_ from MyBaseObject this_ left outer join MyChildObject1 this_1_ on this_.id=this_1_.id left outer join MyChildObject2 this_2_ on this_.id=this_2_.id where case when this_1_.id is not null then one when this_2_.id is not null then two when this_.id is not null then 'MyBaseObject' end=? and (this_.id=? or this_.id=?) limit ? org.hibernate.exception.SQLGrammarException: could not prepare statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:193) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:157) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1881) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1858) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838) at org.hibernate.loader.Loader.doQuery(Loader.java:906) ... Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ONE at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:159) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:183) ... 50 more Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ONE {code} MyBaseObject.java: {code} @Entity @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING) abstract class MyBaseObject { @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long id; @Override public String toString() { return getClass().getSimpleName() + "{" + "id=" + id + '}'; } } {code} MyChildObject1.java: {code} @Entity @DiscriminatorValue("one") class MyChildObject1 extends MyBaseObject { } {code} MyChildObject2.java: {code} @Entity @DiscriminatorValue("two") class MyChildObject2 extends MyBaseObject { } {code}
    via by Peter,
  • I've updated from Hibernate 4.1.7 to Hibernate 4.3. I'm using hsqldb 2.3.2 and I'm encountering an issue with a joined inheritance strategy and a DiscriminatorValue annotation. Hibernate appears to be generating invalid SQL (not quoting a referenced DiscriminatorValue in a query). Code that worked in 4.1.7: {code} criteria.add(Restrictions.eq("class", MyChildObject1.class)); {code} Now causes the following exception: {code} Hibernate: insert into MyBaseObject (id, DTYPE) values (default, 'one') Hibernate: insert into MyChildObject1 (id) values (?) Hibernate: insert into MyBaseObject (id, DTYPE) values (default, 'two') Hibernate: insert into MyChildObject2 (id) values (?) Hibernate: select this_.id as id2_0_0_, this_.DTYPE as DTYPE1_0_0_ from MyBaseObject this_ left outer join MyChildObject1 this_1_ on this_.id=this_1_.id left outer join MyChildObject2 this_2_ on this_.id=this_2_.id where case when this_1_.id is not null then one when this_2_.id is not null then two when this_.id is not null then 'MyBaseObject' end=? and (this_.id=? or this_.id=?) limit ? org.hibernate.exception.SQLGrammarException: could not prepare statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:193) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:157) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1881) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1858) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838) at org.hibernate.loader.Loader.doQuery(Loader.java:906) ... Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: ONE at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) at org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:159) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:183) ... 50 more Caused by: org.hsqldb.HsqlException: user lacks privilege or object not found: ONE {code} MyBaseObject.java: {code} @Entity @Inheritance(strategy = InheritanceType.JOINED) @DiscriminatorColumn(discriminatorType = DiscriminatorType.STRING) abstract class MyBaseObject { @Id @GeneratedValue(strategy = GenerationType.AUTO) public Long id; @Override public String toString() { return getClass().getSimpleName() + "{" + "id=" + id + '}'; } } {code} MyChildObject1.java: {code} @Entity @DiscriminatorValue("one") class MyChildObject1 extends MyBaseObject { } {code} MyChildObject2.java: {code} @Entity @DiscriminatorValue("two") class MyChildObject2 extends MyBaseObject { } {code}
    via by Peter,
  • [aerogear-dev] use oracle database
    via by Unknown author,
  • How to insert new items with Hibernate?
    via Stack Overflow by Click Upvote
    ,
  • How to sort by CLOB column with Hibernate / DB2
    via by Unknown author,
    • org.hibernate.exception.SQLGrammarException: could not prepare statement at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:193) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:157) at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1881) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1858) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838) at org.hibernate.loader.Loader.doQuery(Loader.java:906)

    Users with the same issue

    linxiaolong
    1 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,
    Piz
    2 times, last one,
    Kawada
    18 times, last one,
    11 more bugmates