-->
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.  [ 4 posts ] 
Author Message
 Post subject: unexpected AST node: query
PostPosted: Tue Jul 26, 2005 9:27 am 
Newbie

Joined: Tue Jul 26, 2005 9:17 am
Posts: 4
This HQL throws an exception:

select count(*) from Issue as i where 1=1 AND ((select max(comment.created) from i.comments as comment) BETWEEN :From AND :To)

While this HQL works fine:

select count(*) from Issue as i where 1=1 AND ((select max(comment.created) from i.comments as comment) > :From)

It's probably a bug, isn't it?
jan

Hibernate version: 3.0.5

Full stack trace of any exception that occurs:
unexpected AST node: query
antlr.NoViableAltException
# org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:958)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3458)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1333)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
# org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
# org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
# org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)
# org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)
# org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:427)
# org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
# org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
# org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
# org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 26, 2005 9:29 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Add to JIRA. Probably a trivial fix to the grammar.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 10, 2006 5:54 am 
Newbie

Joined: Mon Oct 10, 2005 1:07 pm
Posts: 13
gavin wrote:
Add to JIRA. Probably a trivial fix to the grammar.


Hi,

according to http://opensource.atlassian.com/projects/hibernate/browse/HHH-795 it was fixed, but it's not clear in what version...

was this fixed in 3.1? I am getting this problem with the following HQL:

Code:
select b
from Batch as b
where b.job.id = :jobId
and ((:luwId - (select min(j.LUWs.id) from Job j where j.id = :jobId) + 1) between b.indexRange.firstIndex and b.indexRange.firstIndex)


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 10, 2006 9:37 am 
Regular
Regular

Joined: Wed Aug 25, 2004 6:23 am
Posts: 91
No - I think that was a seperate probem.

I think that this one is due to the following in hql-sql.g:-

Code:
arithmeticExpr
   : #(PLUS expr expr)         { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(MINUS expr expr)        { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(DIV expr expr)          { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(STAR expr expr)         { prepareArithmeticOperator( #arithmeticExpr ); }
//   | #(CONCAT expr (expr)+ )   { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(UNARY_MINUS expr)       { prepareArithmeticOperator( #arithmeticExpr ); }
   | caseExpr
   ;


changing it to:

Code:
arithmeticExpr
   : #(PLUS exprOrSubquery exprOrSubquery)         { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(MINUS exprOrSubquery exprOrSubquery)        { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(DIV exprOrSubquery exprOrSubquery)          { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(STAR exprOrSubquery exprOrSubquery)         { prepareArithmeticOperator( #arithmeticExpr ); }
//   | #(CONCAT expr (expr)+ )   { prepareArithmeticOperator( #arithmeticExpr ); }
   | #(UNARY_MINUS exprOrSubquery)       { prepareArithmeticOperator( #arithmeticExpr ); }
   | caseExpr
   ;


would probably do the trick.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.