假如人只能自己单独生活,只会考虑自己,他的痛苦将是难以承受的。——帕斯卡
代码很简单:
代码语言:javascript复制userRepository.findBy(Example.of(new User()), x -> x.page(PageRequest.of(0, 1)))
这里repository
需要继承org.springframework.data.repository.query.ReactiveQueryByExampleExecutor
例如:
代码语言:javascript复制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> {
}
使用:
代码语言:javascript复制userRepository.findBy(Example.of(new User()),
x -> x.page(PageRequest.of(0, 1)))
.as(StepVerifier::create)
.expectNextMatches(Streamable::isEmpty).verifyComplete();