How can I translate the following query to detachedCriteria:
select * from (
select a.* ,row_num开发者_运维问答ber() over (partition by hotel_id order by EXECUTION_START_DATE desc) rnk
from HOLIDAY_PACKAGES a
)
where rnk = 1
I don't think you will be able to construct such a query using the Criteria API. The only way to go is through the Native SQL support or in the worst case scenario use a stored procedure.
http://www.nhforge.org/doc/nh/en/index.html#manipulatingdata-nativesql
精彩评论