HQL比较没有日期的时间

时间:2014-11-05 14:39:39

标签: hibernate hql

您好我需要使用像这样的

这样的HQL查询从postgres postgres数据库表中获取数据
SELECT F.flightType, F.obDepartAirport, F.obArriveAirport, F.obDepartDate, F.obArriveDate, F.obFlightNumber, F.ibDepartAirport, F.ibArriveAirport, F.ibDepartDate, F.ibArriveDate, F.ibFlightNumber, F.seatsAvailable, F.id, F.createdAt, F.adultPrice, F.childPrice, F.infantPrice, F.nights, F.supplierCode, F.currency, F.additionalUIDInfo, F.obCabinType, F.ibCabinType
FROM ScannedFlight as F
WHERE
F.obDepartDate >= :fromDateStart AND F.obDepartDate < :fromDateEnd AND F.flightType = :flightType AND F.obDepartAirport IN (:fromAirports) AND F.obArriveAirport IN (:toAirports) AND F.supplierCode in (:operatorCodes) AND F.nights = :nights AND ( CAST (F.obDepartDate AS time) between time :obDepartTimeStart and time :obDepartTimeEnd)
ORDER BY F.adultPrice

( CAST (F.obDepartAirport AS time) between time :obDepartTimeStart and time :obDepartTimeEnd)部分hibernate中的问题不知道postgres函数时间。我的问题是如何只提取时间并进行比较。

1 个答案:

答案 0 :(得分:1)

我使用演员

修复它
( CAST (F.obDepartDate AS time) between CAST(:obDepartTimeStart AS time) and CAST(:obDepartTimeEnd AS time))