-->
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: HQL Aggregate Syntax Eluding me!
PostPosted: Tue Sep 27, 2005 11:22 am 
Newbie

Joined: Tue Sep 27, 2005 11:03 am
Posts: 6
Hibernate version: 2.1.8

Name and version of the database you are using: Postgresql 8.0

I'm struggling with an HQL aggregate issue and I can't seem to solve it :-

I've got a crime record with a one to many associated of notifications. A notification has a property - userAcknowledged. I'm trying to select out the count of crime records that have one or more attached notifications with the user acknowledged flag set. Even the total number of unacknowledged attached notifications would do if thats easier!

I've got something like :-

select count(crRec) from CrimeRecord crRec where crRec.attachedNotifications = some ("
select crRec.attachedNotifications from CrimeRecord crRec where crRec.attachedNotifications.userAcknowledged ='0')

However, the syntax is eluding me.

Can anyone help!?

Thanks!,

Rob Kirkbride


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 11:31 am 
Newbie

Joined: Wed May 25, 2005 10:37 am
Posts: 5
Should be something like this:

Code:
select count(distinct crRec)
from CrimeRecord crRec
left join crRec.attachedNotifications as notif
where
   notif.userAncknowledged = true


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 3:10 am 
Newbie

Joined: Tue Sep 27, 2005 11:03 am
Posts: 6
Thanks that solved it!

Rob


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.