I need to use the TOP qualifier in a subquery in an HQL query.
However I understand that the TOP keyword is not supported in HQL.
I need to get complex aggregate and grouped data (from many tables) using a complex query, based on a singe id returned from a subquery which gets a row by the latest date.
The
subquery needs to be something like
Code:
SELECT TOP 1 s.id FROM Stuff s WHERE s.user = :user ORDER BY s.date DESC
Then the main query gets a pile of useful aggregate and other information based on the one id returned from the subquery.
Of course I can do this using two HQL queries.
I am using Hibernate 3.2.2ga, SQLServer 2005
Thank you!