我有以下代码,使用Specification
构建复杂的where子句。
public interface EmployeeRepository extends
CrudRepository<Employee, String>,
JpaSpecificationExecutor<Employee> {
}
public class Service {
@Autowired
private EmployeeRepository employeeRepository;
public List<Employee> test() {
return employeeRepository.findAll(where(hasNames(List.of("Tom", "Jerry"))).and(hasAges(List.of(20,21))));
}
}
我正在尝试使用r2dbc将此代码转换为响应式。我用ReactiveCrudRepository
代替了CrudRepository
。然而,为了建立复杂的where子句,我需要使用Specification
。我没有看到JpaSpecificationExecutor
的反应版本
public interface EmployeeRepository extends
ReactiveCrudRepository<Employee, String>,
JpaSpecificationExecutor<Employee> { // is there ReactiveJpaSpecificationExecutor?
}
是否有一个响应版本的JpaSpecificationExecutor,或者在响应中构建where子句的方法?
我也在等待标准,但我现在没有看到;-)我需要实现之间:Spring JPA ExampleMatcher比较日期条件
参见类似问题:https://github.com/spring-projects/spring-data-jpa/issues/1331https://github.com/r2dbc/r2dbc-spi/issues/141
也许你现在可以使用Template:https://hantsy.medium.com/update-accessing-rdbms-with-spring-data-r2dbc-a4d118b1669d或infoobip -spring-data-querydsl