-->
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: Complicated Select
PostPosted: Sat Feb 27, 2010 4:03 pm 
Newbie

Joined: Sat Feb 27, 2010 3:46 pm
Posts: 1
I have 2 objects, Book and BookEdition. A Book can have many BookEdition (One to Many). I want to select a list of bookEditions with thier corresponding book, with that bookEdition being the one with the highest publication date for that particular book. I want to limit it to say, the top 10 most recent books editions, but do not want duplicate books, so if 2 book editions for the same book are in the top 10, i want only the most recent one.

I also have another query where I would select only bookEditions where the datePublished is in say the last 90 days from today, and sort them by an attribute of the book (book.score), while still having only the most recent bookEdition for a book and no book duplicates.

So my query would begin like this : Select b, be from Book b, BookEdition be Where b.no = be.bookNo Order By be.datePublished Desc limit 10.

This query of course could have duplicate books in it.

I am at a loss in how to do it.

Thanks!

Eric bouchard


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.