Hi everyone,
I'm having trouble figuring out a good way to efficiently do a query. I have a table that is being used to periodically log server status information. One of the queries I want to do is to get the most recent entry for each server. In sql I would have done this with a temporary table. For a simple example let's say my object has three member variables, host id, timestamp, and status. In sql I would query:
Code:
select HOSTID, TIME_STAMP, STATUS from STATS, ( select HOSTID, max(TIME_STAMP) as MAXTS from STATINFO group by HOSTID ) as FOO where STATS.HOSTID = FOO.HOSTID and STATS.TIME_STAMP = FOO.MAXTS
Obviously, I could do this query in sql, but I really don't want to. The actual object I need to query is much more complicated then the one in my example. It has objects, and sets and maps of objects as member variables, and those objects have other objects. In all there are 12 tables for this one object and all its sub-objects.
So I would appreciate any insight anyone has on a way to do this efficiently with hql.
Thanks,
Ed