r2dbc分页条件查询

简介: r2dbc分页条件查询

代码很简单:

userRepository.findBy(Example.of(new User()), x -> x.page(PageRequest.of(0, 1)))

这里repository需要继承org.springframework.data.repository.query.ReactiveQueryByExampleExecutor

例如:

import org.springframework.data.r2dbc.repository.R2dbcRepository;
import org.springframework.data.repository.query.ReactiveQueryByExampleExecutor;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;

@Repository
public interface UserRepository extends R2dbcRepository<User, Long>, ReactiveQueryByExampleExecutor<User> {
}

使用:

userRepository.findBy(Example.of(new User()),
                x -> x.page(PageRequest.of(0, 1)))
        .as(StepVerifier::create)
        .expectNextMatches(Streamable::isEmpty).verifyComplete();
目录
打赏
0
0
0
0
29
分享
相关文章
MyBatis-Plus - 分页查询 selectPage 返回 total 为 0 解决方案
MyBatis-Plus - 分页查询 selectPage 返回 total 为 0 解决方案
2818 0
jpa实现增删改查,分页,自定义查询,jpql查询
jpa实现增删改查,分页,自定义查询,jpql查询
109 0
【MySQL】:分组查询、排序查询、分页查询、以及执行顺序
【MySQL】:分组查询、排序查询、分页查询、以及执行顺序
310 0
|
10月前
mongoTemplate根据id模糊分页条件查询
mongoTemplate根据id模糊分页条件查询
158 0
九、查询结果排序与分页
九、查询结果排序与分页
121 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等