2014-11-05 61 views
0

你好,我需要获得使用HQL查询从Postgres的Postgres的数据库表中的数据是这样HQL比较次无日期

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)休眠的问题不知道Postgres的作用时间。我的问题是如何提取时间并进行比较。

+0

它你为什么不写,选择F从ScannedFlight为F其中.....我想你写你的所有投影在上面的查询。 – 2014-11-05 14:44:53

+0

不只是部分,并有查询生成器具有相同的“选择”部分和不同的地方。但这不是我的问题 – aleshko 2014-11-05 14:51:35

回答

1

我用固定投

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