How to best compare if the time part of a Date is between two LocalTime values with querydsl?

Viewed 1027

QueryDSL Version 4.1.4 - upgrade not possible at the moment

How to best compare if the time part of a Date is between two LocalTime values with QueryDSL?

Declaration:

private java.time.LocalTime.LocalTime beginTime; -> TIME in postgresql
private java.time.LocalTime.LocalTime endTime;  -> TIME in postgresql
private java.util.Date calltime; -> TIMESTAMP in postgresql

Expressions:

TimeExpression<Date> calltimeTimePath = Expressions.asTime(qTicket.calltime);
TimePath<LocalTime> beginTimePath = qCallCenterTimeslot.beginTime;
TimePath<LocalTime> endTimePath = qCallCenterTimeslot.endTime;

Predicate:

.where(calltimeTimePath.between(beginTimePath, endTimePath));

Exception: Cannot resolve method 'between(com.querydsl.core.type.dsl.TimePath, com.querydsl.core.type.dsl.TimePath)'

Working example:

TimeExpression<LocalTime> testTimeExpression = Expressions.asTime(test);

.where(testTimeExpression.between(beginTimeExpression, endTimeExpression))

So maybe the best way would be to convert TimeExpression from Date to TimeExpression from LocalTime. But I've no clue how to achieve this?


In postgresql I can simply do:

SELECT t.calltime::TIME, *
FROM ticket t
     INNER JOIN call_center_timeslot c
             ON c.id=218
            AND t.calltime::TIME BETWEEN c.begin_time AND c.end_time;

Any thoughts how to best solve it?

0 Answers
Related