java - 如何访问 QueryDSL QuerydslBinderCustomizer 中的跨字段值?
问题描述
如何访问内部的其他查询参数值QuerydslBinderCustomizer
?
我的目标是创建一个departure.between(min, max)
绑定,我想从两个查询参数min
和max
.
问题是方法route.max
内部无法访问该值customize()
,或者至少我不知道如何访问它。
/departures?min=2021-01-01&max=2021-01-30
@Repository
public interface RouteRepository extends JpaRepository<Route, Long>,
QueryDslPredicateExecutor<QRoute>, QuerydslBinderCustomizer<QRoute> {
@Override
default public void customize(QuerydslBindings bindings, QRoute route) {
//value is the 'min' query parameter. HOW can I access the 'max' parameter here??
bindings.bind(route.min).first((path, value) -> route.departure.between(value, route.max));
}
}
@Entity
class Route {
@Id long id;
@Transient LocalDate min, max; //only for the query
LocalDate departure; //real db field
}
解决方案
推荐阅读
- javascript - 使用 Javascript 实现 Live Django Search
- python - 使用 DictReader 且不使用 fieldnames() 方法从 csv 文件中读取标头
- python - 如何将 SMOTE 重采样和特征选择集成到 RFECV 中
- php - 在 Laravel 的主域和子域上持久化身份验证用户 | 会议 | 子域
- python - 将数据附加到现有 Excel 工作表的问题
- javascript - 给定第一个示例,如何复制另一个水平滚动?
- python - 使用 numpy 向量化 else-if 语句函数
- r - 在 Mac 上将多个文件夹中的文件合并到一个文件夹中,或者在 R 中同时读取不同文件夹中的多个文件
- javascript - 执行停止功能时,audio.duration 属性未重置
- javascript - 无法在反应响应轮播中执行条件渲染