-->
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: Multiple columns on a count expression
PostPosted: Mon Mar 08, 2010 4:20 pm 
Newbie

Joined: Mon Mar 08, 2010 4:12 pm
Posts: 2
Hello there!

I need to do a count using multiple columns but I get the following error:

expecting CLOSE, found '('

I searched a lot about this issue and my conclusion is that hibernate does not support count(distinct t.col, t.col2) or something like that. The table I want to do this count has a composite id and once this is a very basic functionality (I can do it in native SQL with no dificulty) I belive it must be a way to do that.

My last try was:

select count(distinct acr.id.numeroSinistro, acr.id.numeroAcordo) from AcordoORM as acr

then i got

select count( acordoorm0_.SINNUM, acordoorm0_.rscacrnum ) from mfrmacr acordoorm0_

but my oracle database does not run that query....


anyone has any idea on how to do this?

regards


Top
 Profile  
 
 Post subject: Re: Multiple columns on a count expression
PostPosted: Tue Mar 09, 2010 8:36 am 
Newbie

Joined: Mon Mar 08, 2010 4:12 pm
Posts: 2
looking at HQL grammar it seems it realy does not support multiple columns on a count expression:

aggregate
: ( SUM^ | AVG^ | MAX^ | MIN^ ) OPEN! additiveExpression CLOSE! { #aggregate.setType(AGGREGATE); }
// Special case for count - It's 'parameters' can be keywords.
| COUNT^ OPEN! ( STAR { #STAR.setType(ROW_STAR); } | ( ( DISTINCT | ALL )? ( path | collectionExpr ) ) ) CLOSE!
| collectionExpr
;

//## collection: ( OPEN query CLOSE ) | ( 'elements'|'indices' OPEN path CLOSE );

collectionExpr
: (ELEMENTS^ | INDICES^) OPEN! path CLOSE!
;

=(


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.