-->
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: Novice question - HQL Aggregate Queries
PostPosted: Tue Jun 30, 2009 2:38 pm 
Newbie

Joined: Mon Mar 08, 2004 12:32 pm
Posts: 7
I've got the following entities:

  • Exercise, with a collection 'participations' of type Participation.
  • Each Participation has a collection of Idea and IdeaReview.
  • Idea and IdeaReview each have a submitter property of type Participation.

I want to produce a table listing each exercise and the number of ideas and idea reviews created by its participants. This isn't HQL, but I'd like to write something like this pseudocode:

select e.title, size(e.participations.ideas), size(e.participations.ideaReviews) from Exercise e

For whatever reason (oxygen starvation as a child, perhaps) I can't figure out the actual HQL for this query, even using the interactive Eclipse HQL tools. I'm assuming I have to do something from the other direction, along the lines of:

where i.submitter in elements(e.participations)

.. but keep stumbling on errors, such as "No table 'idea' defined." (The hibernate mappings work just fine in the application, they're not new.)

Can anyone set me straight? Any nudges in the right direction would be helpful.


Top
 Profile  
 
 Post subject: Re: Novice question - HQL Aggregate Queries
PostPosted: Tue Jun 30, 2009 3:48 pm 
Beginner
Beginner

Joined: Thu Feb 08, 2007 10:40 am
Posts: 46
How about this HQL:

select e.title, size(p.ideas), size(p.ideaReviews) from Exercise e left join e.participations p


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.