- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在研究一些关于如何为 MongoDB 中的上限集合编写 Tailable 游标查询的教程。我发现我可以使用 @Tailable 来实现这一点。例如,像这样:
public interface ReactiveProductRepository extends ReactiveCrudRepository<Product, String>{
@Tailable
Flux<Product> findByName(String name);
}
这就像一个魅力。这也适用于 @Query
注释(在复杂查询的情况下)。
但是如果我想将 ReactiveCrudRepository
中的方法之一设置为 Tailable 该怎么办?例如,findAll
。我能找到的唯一替代方法是在我的存储库中添加这样的方法:
@Tailable
@Query("{}")
Flux<Product> findAllProducts();
这只不过是findAll。我想知道:难道不应该有一个选项来为内置方法指定 @Tailable
功能吗?
有什么想法吗?拥有一个类似于 PagingAndSortingRepository
的新接口(interface) (TailableRepository
) 是否有意义。
最佳答案
由实际实现支持的存储库方法不能更改其行为或被查询方法覆盖。
您可以声明不带参数的查询方法,并为要用作入口点的所需方法提供默认
实现:
public interface LoginEventRepository extends ReactiveCrudRepository<LoginEvent, String> {
@Tailable
Flux<LoginEvent> findPeopleBy();
@Override
default Flux<LoginEvent> findAll(){
return findPeopleBy();
}
}
另请参阅here有关 @Tailable
无参数查询方法的示例。
关于java - 如何在 ReactiveCrudRepository @Tailable 中创建方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48445037/
我正在使用带有对 Elasticsearch 的响应式支持的 spring-data: @Repository public interface UserDocumentRepository exte
我正在研究一些关于如何为 MongoDB 中的上限集合编写 Tailable 游标查询的教程。我发现我可以使用 @Tailable 来实现这一点。例如,像这样: public interface Re
知道为什么下面的代码会返回 null 的单声道吗?我知道为什么契约(Contract)会允许它,但我希望 Spring 代码返回 true 或 false。 public interface Samp
我计划使用 Cassandra 来响应式保存数据。为此,我编写了以下接口(interface): @Repository public interface ContributorStatReposit
是否可以将 Hibernate 和 RDBMS(Mysql、Postgres 等)与 ReactiveCrudRepository 而不是 CrudRepository 一起使用?我用 Spring
是否可以通过 ReactiveCrudRepository 而不是 CrudRepository 使用 Hibernate 和 RDBMS(Mysql、Postgres 等)?我用 Spring Da
我在 Kotlin 和 WebFlux 中有一个示例 SpringBoot 应用程序。我将整个应用程序划分为模块(正如我习惯于从 asp.net 中所做的那样)。 模块: 随处引用的核心(模型、DTO
问题: 我有一个 ReactiveCrudRepository,我想在 RestController 中使用它,但 Spring 发现它不再被注入(inject)。在我将存储库重构为响应式之前(之前是
对于下面的代码,存储库中的获取和更新操作工作正常。但是保存操作并没有将数据持久化到表中。如果我自己实现存储库,它就可以正常工作。将其替换为扩展 ReactiveCrudRepository 的接口(i
我正在使用 webflux 来玩 Spring Boot 2。我正在尝试使用 ReactiveSortingRepository 来简化 redis 操作。 public interface Data
我正在开发一个使用 Kotlin、Spring Boot、Hibernate(全部都是最新版本)的项目,我想让它与 Spring 的 WebFlux 框架 react 。 问题是我无法使用 React
我无法将文档保存到 couchbase。 这是我的代码库。我在 docker 中运行 couchbase。 我使用查询在数据库中手动添加了一个文档。 repo.findAll() 工作正常,但 rep
我正在使用 spring-data-jpa和 spring webflux .当我用 ReactiveCrudRepository 扩展我的 UserRepository 时.我收到以下错误: org
对于JpaRepository有@DataJpaTest 。 @DataJpaTest 允许在 Spring 中对 JPA 存储库进行简单且独立的测试。 我们正在使用spring-data-r2dbc
上下文:我想将数据异步保存到 MongoDb。当 Front(例如 Angular/Mobile)调用 Controller EndPoint 时,它将调用一个 Service 方法,旨在首先将数据保
我是一名优秀的程序员,十分优秀!