0

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.

2
  • Why dont you write select F from ScannedFlight as F where..... I guess you are writing your all projections in above query. Nov 5, 2014 at 14:44
  • Nope only part and there is query generator which has same "select" part and different from and where. But it is not the case of my problem
    – aleshko
    Nov 5, 2014 at 14:51

1 Answer 1

1

I fix it using cast

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.