I had earlier query like this:
public List<Human> findAllHumansWithPets(){
QHuman human = QHuman.human;
QPet pet = QPet.pet;
JPAQuery query = new JPAQuery(entityManager);
//Joda-Time
LocalDate first = new LocalDate(1990, 01, 01);
LocalDate last = new LocalDate(1990, 02, 01);
return query.from(human)
.innerJoin(human.pet, pet)
.where(SQLExpressions.date(human.age).between(first.toDate(), last.toDate()))
.list(order);
}
And it was working just fine. Now I updated age
variable in my Human POJO to use java.time.LocalDate instead of org.joda.time.LocalDate. Querydsl didn't like that and is now complaining about parameter of SQLExpression.date
.
//java.time.LocalDate
LocalDate first = LocalDate.of(1990, 01, 01);
LocalDate last = LocalDate.of(1990, 02, 01);
return query.from(human)
.innerJoin(human.pet, pet)
.where(SQLExpressions.date(human.age).between(first, last))
.list(order);
}
DateTimeExpression<java.lang.Comparable> in SQLExpressions cannot be applied to com.mysema.query.types.path.DatePath<java.time.LocalDate>
I can't seem to find any workaround about this issue. Would be nice to prevent going back to Joda-Time. Any suggestions?
DateExpression.currentDate(LocalDate.class).between(..., ...)
DateExpression.currentDate(LocalDateTime.class).between(..., ...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With