3 Replies Latest reply on Oct 14, 2008 3:22 AM by Adam Warski

    Error running demo app

    Sanne Grinovero Master

      Hello, very nice project!
      I downloaded the trunk from SVN to give a look, I've hit this exception
      running the console demo:

      Oct 13, 2008 12:34:37 PM org.hibernate.util.JDBCExceptionReporter logExceptions
      WARNING: SQL Error: -28, SQLState: S0022
      Oct 13, 2008 12:34:37 PM org.hibernate.util.JDBCExceptionReporter logExceptions
      SEVERE: Column not found: ID in statement [select person_ver0_.id as id3_, person_ver0_._revision as column2_3_, person_ver0_._revision_type as column3_3_, person_ver0_.name as name3_, person_ver0_.surname as surname3_, person_ver0_.address_id as address6_3_ from Person_versions person_ver0_ where person_ver0_._revision_type<>? and person_ver0_._revision=(select max(person_ver1_._revision) from Person_versions person_ver1_ where person_ver1_._revision<=? and person_ver0_.id=person_ver1_.id) and person_ver0_.id=?]
      Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
       at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
       at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
       at org.hibernate.loader.Loader.doList(Loader.java:2216)
       at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
       at org.hibernate.loader.Loader.list(Loader.java:2099)
       at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
       at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
       at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
       at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
       at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
       at org.jboss.envers.query.impl.AbstractVersionsQuery.buildAndExecuteQuery(AbstractVersionsQuery.java:88)
       at org.jboss.envers.query.impl.EntitiesAtRevisionQuery.list(EntitiesAtRevisionQuery.java:82)
       at org.jboss.envers.query.impl.AbstractVersionsQuery.getSingleResult(AbstractVersionsQuery.java:98)
       at org.jboss.envers.reader.VersionsReaderImpl.find(VersionsReaderImpl.java:100)
       at org.jboss.envers.demo.TestConsole.printPersonHistory(TestConsole.java:92)
       at org.jboss.envers.demo.TestConsole.start(TestConsole.java:315)
       at org.jboss.envers.demo.TestConsole.main(TestConsole.java:454)
      Caused by: java.sql.SQLException: Column not found: ID in statement [select person_ver0_.id as id3_, person_ver0_._revision as column2_3_, person_ver0_._revision_type as column3_3_, person_ver0_.name as name3_, person_ver0_.surname as surname3_, person_ver0_.address_id as address6_3_ from Person_versions person_ver0_ where person_ver0_._revision_type<>? and person_ver0_._revision=(select max(person_ver1_._revision) from Person_versions person_ver1_ where person_ver1_._revision<=? and person_ver0_.id=person_ver1_.id) and person_ver0_.id=?]
       at org.hsqldb.jdbc.Util.throwError(Unknown Source)
       at org.hsqldb.jdbc.jdbcPreparedStatement.executeQuery(Unknown Source)
       at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
       at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
       at org.hibernate.loader.Loader.doQuery(Loader.java:674)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
       at org.hibernate.loader.Loader.doList(Loader.java:2213)
       ... 14 more
      


      I just did "list person history" (2), and choose person 1.
      I built it just doing, suing Java 1.5.16:
      ant dist-demo
      cd dist
      java -jar envers-console-demo.jar


      I don't need you to help me on this of course, it's just to let you know.
      regards,

        • 1. Re: Error running demo app
          Adam Warski Master

          Hello,

          thanks for the report :)

          Seems to be something HSQL-related (demo works fine with MySQL).

          I compared the SQL commands generated by the old demo (downloadable from the site) and "trunk" demo, and they are the same, except different aliases. Weird :)

          Adam

          • 2. Re: Error running demo app
            Adam Warski Master

            I found one guy on the web that reported a very similar problem (though he wasn't using hibernate), and the cause was an alias of a table that ended in _0.

            My case is similar: in the old implementation, I was using criteria to generate queries, and the alias was "this_", which worked.

            Now I generate HQL, and Hibernate generates an alias "person_ver0_". With witch HSQLDB doesn't work apperantely :).

            To make things worse, both aliases work when used directly from HSQLDB console ...

            I created a JIRA for that: https://jira.jboss.org/jira/browse/ENVERS-57. Any ideas welcome ;). I don't think you can force a table alias that Hibernate should use, can you?

            --
            Adam

            • 3. Re: Error running demo app
              Adam Warski Master

              Hello,

              I fixed this in trunk, should be working now. It looks like a bug either in HSQLDB or in the dialect (as the query only fails to execute when run by hibernate, not from the console). I'll create a test case and post a bug on hibernate jira when I'll have some time.

              Adam