After too much trial and error and reading all the HQL material I could find I was hoping someone might have experience with the following and point me in the right direction.
I currently use the following SQL statement to retrieve projected data associated with only the highest versioned Name, Version pairs listed in a table:
Code:
SELECT r.rule_id, r.rule_name, r.version
FROM rule r, (SELECT MAX(version) AS maxver, name FROM rule GROUP BY name) maxresults
WHERE r.name = maxresults.name AND r.version = maxresults.maxver
The above statement returns results similar to the following:
id | Name | Version
--------------------
a4 | Name1 | 4 (where the table contains version #s 1 - version # listed)
g3 | Name2 | 1
s2 | Name3 | 8
Is it possible to use a HQL select statement in a From clause to achieve similar results as with SQL?
Is it possible to use HQL to retrieve an entity object (as opposed to using projection to retrieve only id, name, version) as result from an HQL version of the SQL Query?
Any help/suggestions are greatly appreciated.
jason