-->
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.  [ 1 post ] 
Author Message
 Post subject: Not able to get an MySQL statement transferred to HQL
PostPosted: Fri Apr 23, 2010 4:47 am 
Newbie

Joined: Mon Jun 25, 2007 3:06 pm
Posts: 5
Hi all,

actually I am not able to transfer this MySQL statement to an HQL statement

Code:
SELECT count(*) / count(distinct month(c.created_date_time),year(c.created_date_time)) as averg
FROM comments c


My HQL lines are:
Code:
String hql = "select count(*) / count(distinct month(c.createdDateTime)) as avrg from Comment c";
Float averageBlogsPerYear = (Float) getSession().createQuery(hql).uniqueResult();


If I run it, Hibernate throws this exception:

Code:
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, column 39 [select count(*) / count(distinct month(c.createdDateTime)) as avrg from Comment c


Actually I am lost a bit. Would appreciate any help on this.

Thanks in advance
John


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

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.