简体   繁体   中英

How to convert SQL- Query with subselect into HQL Query?

I would like to convert following Query into HQL Query. How can i do?

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

, should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM