org.hibernate.exception.SQLGrammarException: could not prepare statement

Hibernate JIRA | Anders Wallgren | 3 years ago
  1. 0

    Doing a batch update such as {{update versioned Animal set weight = 69 where weight = 0}} generates a SQLGrammarException. {code} org.hibernate.exception.SQLGrammarException: could not prepare statement at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:91) at org.hibernate.hql.spi.TableBasedUpdateHandlerImpl.execute(TableBasedUpdateHandlerImpl.java:163) at org.hibernate.hql.internal.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:65) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:415) at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282) at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1290) at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116) at org.hibernate.test.batch.joinedInheritence.BatchVersionedUpdateOfJoinedHierarchyTest.testUpdateVersionedWithWhereClause(BatchVersionedUpdateOfJoinedHierarchyTest.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:62) Caused by: org.h2.jdbc.JdbcSQLException: Table "ANIMAL0_" not found; SQL statement: update Animal set animal0_.version=animal0_.version+1, weight=69 where (id) IN (select id from HT_Animal) [42102-145] at org.h2.message.DbException.getJdbcSQLException(DbException.java:327) at org.h2.message.DbException.get(DbException.java:167) at org.h2.message.DbException.get(DbException.java:144) at org.h2.command.Parser.readTableColumn(Parser.java:632) at org.h2.command.Parser.parseUpdate(Parser.java:664) at org.h2.command.Parser.parsePrepared(Parser.java:413) at org.h2.command.Parser.parse(Parser.java:274) at org.h2.command.Parser.parse(Parser.java:246) at org.h2.command.Parser.prepare(Parser.java:200) at org.h2.command.Parser.prepareCommand(Parser.java:213) at org.h2.engine.Session.prepareLocal(Session.java:423) at org.h2.engine.Session.prepareCommand(Session.java:373) at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1056) at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71) at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:233) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:98) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182) ... 20 more {code}

    Hibernate JIRA | 3 years ago | Anders Wallgren
    org.hibernate.exception.SQLGrammarException: could not prepare statement
  2. 0

    Doing a batch update such as {{update versioned Animal set weight = 69 where weight = 0}} generates a SQLGrammarException. {code} org.hibernate.exception.SQLGrammarException: could not prepare statement at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:91) at org.hibernate.hql.spi.TableBasedUpdateHandlerImpl.execute(TableBasedUpdateHandlerImpl.java:163) at org.hibernate.hql.internal.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:65) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:415) at org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282) at org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1290) at org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116) at org.hibernate.test.batch.joinedInheritence.BatchVersionedUpdateOfJoinedHierarchyTest.testUpdateVersionedWithWhereClause(BatchVersionedUpdateOfJoinedHierarchyTest.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:62) Caused by: org.h2.jdbc.JdbcSQLException: Table "ANIMAL0_" not found; SQL statement: update Animal set animal0_.version=animal0_.version+1, weight=69 where (id) IN (select id from HT_Animal) [42102-145] at org.h2.message.DbException.getJdbcSQLException(DbException.java:327) at org.h2.message.DbException.get(DbException.java:167) at org.h2.message.DbException.get(DbException.java:144) at org.h2.command.Parser.readTableColumn(Parser.java:632) at org.h2.command.Parser.parseUpdate(Parser.java:664) at org.h2.command.Parser.parsePrepared(Parser.java:413) at org.h2.command.Parser.parse(Parser.java:274) at org.h2.command.Parser.parse(Parser.java:246) at org.h2.command.Parser.prepare(Parser.java:200) at org.h2.command.Parser.prepareCommand(Parser.java:213) at org.h2.engine.Session.prepareLocal(Session.java:423) at org.h2.engine.Session.prepareCommand(Session.java:373) at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1056) at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71) at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:233) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:98) at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182) ... 20 more {code}

    Hibernate JIRA | 3 years ago | Anders Wallgren
    org.hibernate.exception.SQLGrammarException: could not prepare statement
  3. 0

    CachedRowSet Support

    Google Groups | 3 years ago | da...@dandymadeproductions.com
    org.h2.jdbc.JdbcSQLException: Column "NAME" not found; SQL statement: INSERT INTO KEY_TABLES.PUBLIC."key_table5" (name, color, price) VALUES (?, ?, ?) [42122-175]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    H2Data cannot cope with periods in column names

    GitHub | 2 years ago | dpisarenko
    java.io.IOException: java.sql.SQLException: org.h2.jdbc.JdbcSQLException: Unbekannter Datentyp: "." Unknown data type: "."; SQL statement: CREATE TABLE table (user.urn VARCHAR PRIMARY KEY,domain.name CLOB,domain.key CLOB,domain.secret CLOB,domain.region CLOB,domain.bucket CLOB,domain.syslog CLOB) [50004-176]
  6. 0

    JdbcSQLException: Table "FILECHECKS" not found

    GitHub | 2 years ago | eallik
    org.h2.jdbc.JdbcSQLException: Table "FILECHECKS" not found; SQL statement: select x2."id", x2."filename", x2."timestamp" from "FILECHECKS" x2 [42102-182]

  1. batwalrus76 1 times, last 6 days ago
  2. kjhdofjosvs 2 times, last 4 weeks ago
  3. Luka 4 times, last 2 months ago
  4. andyglick 1 times, last 10 months ago
17 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.h2.jdbc.JdbcSQLException

    Table "ANIMAL0_" not found; SQL statement: update Animal set animal0_.version=animal0_.version+1, weight=69 where (id) IN (select id from HT_Animal) [42102-145]

    at org.h2.message.DbException.getJdbcSQLException()
  2. H2 Database Engine
    JdbcConnection.prepareStatement
    1. org.h2.message.DbException.getJdbcSQLException(DbException.java:327)
    2. org.h2.message.DbException.get(DbException.java:167)
    3. org.h2.message.DbException.get(DbException.java:144)
    4. org.h2.command.Parser.readTableColumn(Parser.java:632)
    5. org.h2.command.Parser.parseUpdate(Parser.java:664)
    6. org.h2.command.Parser.parsePrepared(Parser.java:413)
    7. org.h2.command.Parser.parse(Parser.java:274)
    8. org.h2.command.Parser.parse(Parser.java:246)
    9. org.h2.command.Parser.prepare(Parser.java:200)
    10. org.h2.command.Parser.prepareCommand(Parser.java:213)
    11. org.h2.engine.Session.prepareLocal(Session.java:423)
    12. org.h2.engine.Session.prepareCommand(Session.java:373)
    13. org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1056)
    14. org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:71)
    15. org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:233)
    15 frames
  3. Hibernate
    QueryImpl.executeUpdate
    1. org.hibernate.engine.jdbc.internal.StatementPreparerImpl$1.doPrepare(StatementPreparerImpl.java:98)
    2. org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:182)
    3. org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:188)
    4. org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareStatement(StatementPreparerImpl.java:91)
    5. org.hibernate.hql.spi.TableBasedUpdateHandlerImpl.execute(TableBasedUpdateHandlerImpl.java:163)
    6. org.hibernate.hql.internal.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:65)
    7. org.hibernate.hql.internal.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:415)
    8. org.hibernate.engine.query.spi.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:282)
    9. org.hibernate.internal.SessionImpl.executeUpdate(SessionImpl.java:1290)
    10. org.hibernate.internal.QueryImpl.executeUpdate(QueryImpl.java:116)
    10 frames
  4. org.hibernate.test
    BatchVersionedUpdateOfJoinedHierarchyTest.testUpdateVersionedWithWhereClause
    1. org.hibernate.test.batch.joinedInheritence.BatchVersionedUpdateOfJoinedHierarchyTest.testUpdateVersionedWithWhereClause(BatchVersionedUpdateOfJoinedHierarchyTest.java:42)
    1 frame
  5. Java RT
    DelegatingMethodAccessorImpl.invoke
    1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    3 frames
  6. JUnit
    FrameworkMethod.invokeExplosively
    1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    3 frames
  7. A Hibernate O/RM Module
    ExtendedFrameworkMethod.invokeExplosively
    1. org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63)
    1 frame
  8. JUnit
    FailOnTimeout$StatementThread.run
    1. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    2. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    3. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    4. org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:62)
    4 frames