-->
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: GROUP BY parser error
PostPosted: Fri Jan 28, 2005 8:23 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
I'm trying to use the following HQL query:
Code:
select TO_CHAR(order.sentdate, 'MM'), sum( order.ordertotal )
from cinetica.ejb.cart.OrderData order
where TO_CHAR(order.sentdate, 'YYYY') = ?
group by TO_CHAR(order.sentdate, 'MM')


and I get the error:
Code:
net.sf.hibernate.QueryException: BY expected after GROUP or ORDER: where [select TO_CHAR(order.sentdate, 'MM'), sum( order.ordertotal
) from cinetica.ejb.cart.OrderData order where TO_CHAR(order.sentdate, 'YYYY') = ? group by TO_CHAR(order.sentdate, 'MM')]
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:33)
        at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
        at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1563)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1534)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[snip]


The error message has no sense, so I suppose the problem regards the use of the function.

Hibernate version: Hibernate 2.1, Hibernate 3 beta 2 (using classic package, didn't tested with new antlr)

Full stack trace of any exception that occurs:
see above

Name and version of the database you are using:
Oracle 9.2.0.5

Regards,

Marco


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 8:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Using "order" as an alias is pretty dodgy... its a keyword ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 28, 2005 10:59 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Ooops, didn't noticed, my fault.
Anyway, I renamed the alias to 'ordine' and I get a different error:
Code:
net.sf.hibernate.QueryException: undefined alias: TO_CHAR [select TO_CHAR(ordine.sentDate, 'MM'), sum( ordine.orderTotal ) from cineti
ca.ejb.cart.OrderData ordine where TO_CHAR(ordine.sentDate, 'YYYY') = ? group by TO_CHAR(ordine.sentDate, 'MM')]
        at net.sf.hibernate.hql.PathExpressionParser.token(PathExpressionParser.java:103)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
        at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:170)
        at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
        at net.sf.hibernate.hql.ClauseParser.end(ClauseParser.java:114)
        at net.sf.hibernate.hql.PreprocessingParser.end(PreprocessingParser.java:143)
        at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:30)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
        at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
        at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
        at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1563)
        at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1534)
        at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
[snip]

_________________
--
Marco


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.