我想将以下查询转换为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'

最佳答案

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'");


, 应该管用。

08-03 17:57