我正在尝试为两个日期(从,到)生成 BETWEEN 条件。其中之一可以为空,在这种情况下我被迫使用 lessThan、greaterThan 而不是 Between 。还有别的办法吗?
尝试使用标准 jooq 的 Between() 方法
import static org.jooq.impl.DSL.*;
Date from = ...; // Your from date
Date to = ...; // Your to date
// Assuming you have a field "dateField" in your table
Field<Date> dateField = ...;
Condition condition = dateField.between(from, to)
.or(dateField.greaterOrEqual(from).and(dateField.lessOrEqual(to)))
.or(dateField.isNull());
// Now you can use the "condition" in your query