如何将带有subselect的SQL-Query转换为HQL查询?

时间:2010-06-08 08:34:52

标签: java hibernate

我想将以下Query转换为HQL查询。我该怎么办?

select * from gpsdata where mobileunitid = '2090818044' and gpsdate in (select gpsdate from gpsdata where mobileunitid = '2090818044' ORDER BY gpsdate DESC LIMIT 1 ) and gpsstatus='true'

1 个答案:

答案 0 :(得分:1)

Query q = session.createQuery("from GpsData where mobileUnitId = '2090818044' and gpsDate in (select gpsDate from GpsData where mobileUnitId = '2090818044' ORDER BY gpsDate DESC LIMIT 1 ) and gpsStatus='true'")应该有用。