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.  [ 3 posts ] 
Author Message
 Post subject: HQL error on parameterized expression in function
PostPosted: Tue Dec 27, 2005 1:36 am 
Newbie

Joined: Mon Mar 21, 2005 12:27 am
Posts: 17
Hi,

I consistently got the error below whenever I have a parameterized expression inside a function call in the where clause.

I have experimented with different HQL to narrow down the simpliest queries that produce the error and found this seems like a parsing/AST issues.

Note: just using constant expression or simple parameter in function calls are OK.

My Hibernate version 3.0.

Any help?

Thanks.

---------------------
HQL:

Quote:
// error
select t from AnyTable t where mod(:m - 2, 3) = 0;

// error
select t from AnyTable t where mod((0 + :m - 2), 3) = 0;

// error
select t from AnyTable t where min(:m - 2, 3) = 0;

// BUT these are OK!
select t from AnyTable t where mod(:m, 3) = 0;

// OK
select t from AnyTable t where mod(15 - 5, 3) = 0;


Error:


Quote:
java.lang.ClassCastException: org.hibernate.hql.ast.SqlNode
at org.hibernate.hql.ast.ArithmeticNode.getDataType(ArithmeticNode.java:12)
at org.hibernate.hql.ast.SessionFactoryHelper.findFunctionReturnType(SessionFactoryHelper.java:188)
at org.hibernate.hql.ast.MethodNode.dialectFunction(MethodNode.java:55)
at org.hibernate.hql.ast.MethodNode.resolve(MethodNode.java:43)
at org.hibernate.hql.ast.HqlSqlWalker.processFunction(HqlSqlWalker.java:538)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.functionCall(HqlSqlBaseWalker.java:2045)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:933)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:3713)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:3190)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:1405)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:599)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:404)
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)
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.SessionImpl.getQueries(SessionImpl.java:880)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:830)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

_________________
Hacking Bear


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 27, 2005 1:39 am 
Newbie

Joined: Mon Mar 21, 2005 12:27 am
Posts: 17
Also The parameter is just set an integer:

oql.setParameter("m", 15);

_________________
Hacking Bear


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 28, 2005 2:22 am 
Newbie

Joined: Mon Mar 21, 2005 12:27 am
Posts: 17
I found the answer: upgrading to 3.1 would fix this

_________________
Hacking Bear


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