-->
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: Query working from command line,unable to execute from HQL
PostPosted: Mon Mar 01, 2004 1:43 am 
Newbie

Joined: Mon Mar 01, 2004 12:27 am
Posts: 3
Location: KL, Malaysia
I am using mysql, my query includes some of date functions. Query working fine from commnadline.. but when i tried to execute from HQL it is throwing QUERYEXCEPTION.

my query is :
SELECT to_days(now()) - to_days(DATE_ADD(u.last_passwd_change, INTERVAL (ga.password_expiry_period - ga.password_pre_expiry_notify) DAY)) as expiryDate from user as u, global_attributes as ga;

Exception details:

[STDERR] javax.ejb.FinderException: net.sf.hibernate.QueryException: aggregate function expected before (
in SELECT [SELECT (to_days(now()) - to_days(DATE_ADD(u.lastPasswordChange, INTERVAL (ga.passwordExpiryPeriod - ga.passwordPreExpiryNotify) DAY))) from com.mlifestyle.etud.model.common.User as u, com.mlifestyle.etud.model.common.GlobalAttributes as ga WHERE u.userId = ?]
at net.sf.hibernate.hql.SelectParser.token(SelectParser.java:91)
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) .......etc...

advance thanks...

earlier advice should be appreciatable....


Prasad Kavuri.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 3:54 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Sorry HQL does not currently support expressions or multiple argument functions in the select clause. V2.2 is planned to introduce a new HQL parser which makes this much easier to do.

NOTE: As extra information - HQL functions must be know to the dialect you are using. Currently, very few dialects have extra functions defined in them. Check Oracle Dialect as an example.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 01, 2004 3:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You could use direct JDBC or the SQL query interface to do this.


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.