Reputation: 385
Hello i need to get data from postgres postgres DB table using HQL query like this
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
The problem in section ( CAST (F.obDepartAirport AS time) between time :obDepartTimeStart and time :obDepartTimeEnd)
hibernate dont know postgres function time. My question how to extract only time and compare it.
Upvotes: 0
Views: 1196
Reputation: 385
I fix it using cast
( CAST (F.obDepartDate AS time) between CAST(:obDepartTimeStart AS time) and CAST(:obDepartTimeEnd AS time))
Upvotes: 1