-->
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.  [ 2 posts ] 
Author Message
 Post subject: Is it possible to use coalesce inside of count in HQL?
PostPosted: Thu Aug 11, 2011 11:46 am 
Newbie

Joined: Thu Aug 11, 2011 11:41 am
Posts: 2
I am trying to do a count(distinct coalesce(value, value)) and I am getting a syntax exception. Is this meant to be supported or not going to happen? Here is a simple example of what I'm doing

Quote:
select count(distinct coalesce(ord.externalOrderNumber, ord.orderNumber)) from Order ord


This is throwing:
Quote:
org.hibernate.hql.ast.QuerySyntaxException: expecting CLOSE


Please keep in mind this is not the real world example since the order table will be distinct. What I'm doing a distinct on is off of a join and I wanted to keep this post simple.


Top
 Profile  
 
 Post subject: Re: Is it possible to use coalesce inside of count in HQL?
PostPosted: Thu Aug 11, 2011 12:00 pm 
Newbie

Joined: Thu Aug 11, 2011 11:41 am
Posts: 2
Here is the stacktrace:

Quote:
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:284)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:182)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)


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