org.hibernate.hql.ast.QuerySyntaxError

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.

  • Hibernate 3 rc1 breaks grouping by functions. It complains about finding an open paren after the 'group by'. http://forum.hibernate.org/viewtopic.php?t=939313 org.hibernate.hql.ast.QuerySyntaxError: unexpected token: ( near line 1, column 97 [select sum(t.clicks), date(t.date) from hdc.Tracker t where t.listing.merchant = ? group by date(t.date) order by sum(t.clicks)] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:74) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:214) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814) at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:850) at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41) at hdc.Test1.doTest5(Test1.java:241) at hdc.Test1.main(Test1.java:317) Caused by: line 1:97: unexpected token: ( at org.hibernate.hql.antlr.HqlBaseParser.groupByClause(HqlBaseParser.java:896) at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:704) at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:227) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:150) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:208) ... 8 more
    via by Jarod,
  • Hibernate 3 rc1 breaks grouping by functions. It complains about finding an open paren after the 'group by'. http://forum.hibernate.org/viewtopic.php?t=939313 org.hibernate.hql.ast.QuerySyntaxError: unexpected token: ( near line 1, column 97 [select sum(t.clicks), date(t.date) from hdc.Tracker t where t.listing.merchant = ? group by date(t.date) order by sum(t.clicks)] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:74) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:214) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814) at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:850) at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41) at hdc.Test1.doTest5(Test1.java:241) at hdc.Test1.main(Test1.java:317) Caused by: line 1:97: unexpected token: ( at org.hibernate.hql.antlr.HqlBaseParser.groupByClause(HqlBaseParser.java:896) at org.hibernate.hql.antlr.HqlBaseParser.queryRule(HqlBaseParser.java:704) at org.hibernate.hql.antlr.HqlBaseParser.selectStatement(HqlBaseParser.java:227) at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:150) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:208) ... 8 more
    via by Jarod,
  • Using Left Joins in HQL on 3 Tables
    via Stack Overflow by Asuthosh Sharma
    ,
  • [Closed] expecting IDENT, found '.' - Genuitec
    via by Unknown author,
  • 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
    via by Robert Watkins,
  • 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
    via by Roland Scheel,
    • org.hibernate.hql.ast.QuerySyntaxError: unexpected token: ( near line 1, column 97 [select sum(t.clicks), date(t.date) from hdc.Tracker t where t.listing.merchant = ? group by date(t.date) order by sum(t.clicks)] at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:74) at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:214) at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:127) at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83) at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414) at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:814) at org.hibernate.impl.SessionImpl.iterate(SessionImpl.java:850) at org.hibernate.impl.QueryImpl.iterate(QueryImpl.java:41) at hdc.Test1.doTest5(Test1.java:241) at hdc.Test1.main(Test1.java:317)
    No Bugmate found.