-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Unexpected end of subree error.
PostPosted: Mon Nov 28, 2005 2:57 pm 
Newbie

Joined: Mon Nov 28, 2005 2:17 pm
Posts: 1
Hibernate version:
hibernate-Using 3.0.3, the problem also occurs with 3.1 rc3

Name and version of the database you are using:
Oracle 9i

The generated HQL:
SELECT dto FROM gov.va.med.domain.model.Cytology dto LEFT JOIN FETCH dto.institution LEFT JOIN FETCH dto.institution.state LEFT join fetch dto.cytologySpecimens WHERE dto.patient.id = :userId AND dto.finalizationDate <= sysdate - 7

The above hql results in the following error: Error> <org.hibernate.hql.PARSER> <000000> <<AST>: unexpected end of subtree>

Stack trace:

org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [SELECT dto FROM gov.va.med.domain.model.Cytology dto LEFT JOIN FETCH dto.institution LEFT JOIN FETCH dto.institution.state LEFT join fetch dto.cytologySpecimens WHERE dto.patient.id = :userId AND dto.finalizationDate <= sysdate - 7 AND dto.id IN ()]
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:59)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:223)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:156)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:103)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:72)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:52)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:108)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1007)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at gov.va.med.domain.persistence.util.HibernateTableLoader.getRows(HibernateTableLoader.java:119)
at gov.va.med.domain.persistence.orm.dao.CytologiesDAOTest.testCytologyHoldForReview(CytologiesDAOTest.java:93)
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:324)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:436)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:311)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: <AST>: unexpected end of subtree
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2933)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:686)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:542)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4233)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.inRhs(HqlSqlBaseWalker.java:4142)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3825)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1756)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1684)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:774)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:575)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:279)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:227)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:216)
... 23 more



If I change the < to a >, or change the minus to a plus, then it works.

I also get the same error if I try:
AND NOT dto.finalizationDate <= sysdate - 7

Parenthesis don't make a difference.
If anyone can provide a workaround to this problem I'd appreciate it.

Thanks.


Top
 Profile  
 
 Post subject: as a parameter
PostPosted: Tue Nov 29, 2005 7:07 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
could you pass sysdate - 7 as a parameter to the HQL so it will not confuse HQL parser?

Like this
WHERE dto.patient.id = :userId AND dto.finalizationDate <= :sysdateParam

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.