I have the following query in oracle that I want to use in hibernate but cannot work out how to use the rownum variable in an inner query. The query is as follows:
select emp.prof_key, emp.prof_display_name
from empinst.emp emp
where emp.prof_key IN (select x.object_key
from (select event.object_key as object_key
from empinst.eventlog event
where event.event_name = 'profiles.created'
and event.event_source = 'Profiles'
order by event.created desc) x
where rownum <= 10)
The only way that I can work out how to do it is to break the query into two parts but I assume there must be a more efficient way to do it in hibernate.
Thanks in advance.
Michael.