org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: 'A' [ from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED ]

Hibernate JIRA | Robert Watkins | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    In migration from Hibernate 2.1.6 to Hibernate 3.0, a named query stopped working. It referenced a string constant. The reported error was a syntax error. Example HSQL: from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED [ Foo.STATUS_APPROVED = new Character('A') ] Error: 18/04/2005 17:16:38 org.hibernate.impl.SessionFactoryImpl <init> SEVERE: Error in named query: Booking.getCheckinsForDay org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: 'A' [ from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED ] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63) at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:180) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:146) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:375) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054) at foo.bar.HibernateConfigTest.testCreateSessionFactory(HibernateConfigTest.java:152) ... The workaround (once the error message is diagnosed) seems to be to place the constant in quotes. However, I'm yet to be able to test it to see if this does the job, or if it merely makes it look for the constant name instead. Possibly-good HSQL: from Foo foo where foo.status = 'foo.bar.Foo.STATUS_APPROVED' This was not a problem under Hibernate 2.1.6

    Hibernate JIRA | 1 decade ago | Robert Watkins
    org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: 'A' [ from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED ]
  2. 0

    In migration from Hibernate 2.1.6 to Hibernate 3.0, a named query stopped working. It referenced a string constant. The reported error was a syntax error. Example HSQL: from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED [ Foo.STATUS_APPROVED = new Character('A') ] Error: 18/04/2005 17:16:38 org.hibernate.impl.SessionFactoryImpl <init> SEVERE: Error in named query: Booking.getCheckinsForDay org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: 'A' [ from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED ] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63) at org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:180) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:146) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:375) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054) at foo.bar.HibernateConfigTest.testCreateSessionFactory(HibernateConfigTest.java:152) ... The workaround (once the error message is diagnosed) seems to be to place the constant in quotes. However, I'm yet to be able to test it to see if this does the job, or if it merely makes it look for the constant name instead. Possibly-good HSQL: from Foo foo where foo.status = 'foo.bar.Foo.STATUS_APPROVED' This was not a problem under Hibernate 2.1.6

    Hibernate JIRA | 1 decade ago | Robert Watkins
    org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: 'A' [ from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED ]
  3. 0

    CREATE OR REPLACE PACKAGE anypackage IS function anyfunction return number; END; / CREATE OR REPLACE PACKAGE body anypackage IS function anyfunction return number is BEGIN return 0; END; END; <query name="anyquery"><![CDATA[ from AnyObject obj order by anypackage.anyfunction(obj.id) ]]> </query> Exception at Runtime: 11:17:46,574 ERROR SessionFactoryImpl:298 - Error in named query: anyquery org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: . [ from AnyObject obj order by anypackage.anyfunction(obj.id) ] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:196) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:425) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:386) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:289) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055) at de.tmobile.cs.db.AbstractCSDatabase.<init>(AbstractCSDatabase.java:94) at de.tmobile.cs.db.CSDatabase.<init>(CSDatabase.java:13) at de.tmobile.cs.db.CSDatabase.getInstance(CSDatabase.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at de.tmobile.cs.dbrt.SessionFactoryProvider.<clinit>(SessionFactoryProvider.java:53) at de.tmobile.cs.db.AutomaticQueryTest.testQueries(AutomaticQueryTest.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.textui.TestRunner.doRun(TestRunner.java:116) at junit.textui.TestRunner.doRun(TestRunner.java:109) at junit.textui.TestRunner.run(TestRunner.java:72) at junit.textui.TestRunner.run(TestRunner.java:57) at de.tmobile.cs.db.AutomaticQueryTest.main(AutomaticQueryTest.java:150) Caused by: <AST>:0:0: unexpected AST node: . at org.hibernate.hql.antlr.HqlSqlBaseWalker.identifier(HqlSqlBaseWalker.java:1754) at org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:1992) at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:933) at org.hibernate.hql.antlr.HqlSqlBaseWalker.orderExprs(HqlSqlBaseWalker.java:1190) at org.hibernate.hql.antlr.HqlSqlBaseWalker.orderClause(HqlSqlBaseWalker.java:1166) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:449) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189) ... 32 more

    Hibernate JIRA | 1 decade ago | Roland Scheel
    org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: . [ from AnyObject obj order by anypackage.anyfunction(obj.id) ]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    CREATE OR REPLACE PACKAGE anypackage IS function anyfunction return number; END; / CREATE OR REPLACE PACKAGE body anypackage IS function anyfunction return number is BEGIN return 0; END; END; <query name="anyquery"><![CDATA[ from AnyObject obj order by anypackage.anyfunction(obj.id) ]]> </query> Exception at Runtime: 11:17:46,574 ERROR SessionFactoryImpl:298 - Error in named query: anyquery org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: . [ from AnyObject obj order by anypackage.anyfunction(obj.id) ] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:196) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:425) at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:386) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:289) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1055) at de.tmobile.cs.db.AbstractCSDatabase.<init>(AbstractCSDatabase.java:94) at de.tmobile.cs.db.CSDatabase.<init>(CSDatabase.java:13) at de.tmobile.cs.db.CSDatabase.getInstance(CSDatabase.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at de.tmobile.cs.dbrt.SessionFactoryProvider.<clinit>(SessionFactoryProvider.java:53) at de.tmobile.cs.db.AutomaticQueryTest.testQueries(AutomaticQueryTest.java:141) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at junit.textui.TestRunner.doRun(TestRunner.java:116) at junit.textui.TestRunner.doRun(TestRunner.java:109) at junit.textui.TestRunner.run(TestRunner.java:72) at junit.textui.TestRunner.run(TestRunner.java:57) at de.tmobile.cs.db.AutomaticQueryTest.main(AutomaticQueryTest.java:150) Caused by: <AST>:0:0: unexpected AST node: . at org.hibernate.hql.antlr.HqlSqlBaseWalker.identifier(HqlSqlBaseWalker.java:1754) at org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:1992) at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:933) at org.hibernate.hql.antlr.HqlSqlBaseWalker.orderExprs(HqlSqlBaseWalker.java:1190) at org.hibernate.hql.antlr.HqlSqlBaseWalker.orderClause(HqlSqlBaseWalker.java:1166) at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:449) at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201) at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151) at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189) ... 32 more

    Hibernate JIRA | 1 decade ago | Roland Scheel
    org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: . [ from AnyObject obj order by anypackage.anyfunction(obj.id) ]
  6. 0

    Named query error(Very urgent!!!)

    Coderanch | 1 decade ago | renga ram
    org.hibernate.hql.ast.QuerySyntaxError: unexpected AST node: ( [select link, userTargetedContent.displayName from com.wamu.dashboard.hotlinks.HotLink link, com.wamu.dashboard.security.permission.UserTargetedContent userTargetedContent where link.userPermissionCode = userTargetedContent.userPermissionCode and link.userPermissionCode (:userPermissionCode) order by link.userPermissionCode, link.displayName]

    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.hibernate.hql.ast.QuerySyntaxError

      unexpected AST node: 'A' [ from Foo foo where foo.status = foo.bar.Foo.STATUS_APPROVED ]

      at org.hibernate.hql.ast.ErrorCounter.throwQueryException()
    2. Hibernate HQL/JP-QL Parser
      QueryTranslatorImpl.compile
      1. org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)
      2. org.hibernate.hql.ast.QueryTranslatorImpl.generate(QueryTranslatorImpl.java:180)
      3. org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:146)
      4. org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
      4 frames
    3. Hibernate
      SessionFactoryImpl.<init>
      1. org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)
      2. org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:375)
      3. org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:278)
      3 frames
    4. Hibernate
      Configuration.buildSessionFactory
      1. org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1054)
      1 frame
    5. foo.bar
      HibernateConfigTest.testCreateSessionFactory
      1. foo.bar.HibernateConfigTest.testCreateSessionFactory(HibernateConfigTest.java:152)
      1 frame