-->
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: Filtering on max value in sub query
PostPosted: Fri Oct 30, 2015 10:08 am 
Newbie

Joined: Fri Oct 30, 2015 9:56 am
Posts: 1
Hi all,

I am writing a Tv guide and I have the following object structure. I have a Program class that has a list of episodes and each episode has a list of broadcasts.

Now I want to display a list of episodes beloning to a certain program of which the first broadcast is now later than 2 weeks ago. So I want to get all the episodes that have been aired for the first time in the last 2 weeks.

I have tried using sub queries however no luck getting the right results. I have found the right SQL command with the following:

Code:
select id, (SELECT MIN(startDate) AS minStartDate FROM broadcasts where episode_id=e.id) from episodes e where e.programId=?


This generates a list of episodes of a certain program and the first broadcast airtime for that episode. How can I convert this into a query (HQL or preferably (Detached)Criteria)?

Thanks in advanced,
Martijn


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.