【发布时间】:2019-09-18 12:59:31
【问题描述】:
在我的 Java 项目中,使用 SeedStack,我有查询以使用如下规范从聚合中检索数据:
更新:已修复代码示例以显示正确的返回类型方法
public interface ProductRepository extends Repository<Product, ProductId> {
default Stream<Product> discontinuedProducts() {
return get(getSpecificationBuilder().of(Product.class)
.property("discontinued").equalTo(true)
.build()
);
}
}
为了避免潜在的内存不足错误,我想使用分页来拆分在某些存储库查询中检索到的数据。
此外,我想使用与字符串数据存储库中现有的分页功能非常相似的东西。我想保留结果的一些元素(而不是全部)并通过“页面”处理它们,而不将所有数据结果保存在 Collection 中。
Spring 中的分页和排序: https://docs.spring.io/spring-data/rest/docs/2.0.0.M1/reference/html/paging-chapter.html
但是,我阅读了 SeedStack 文档并没有找到此功能。
SeedStack 中的存储库: http://seedstack.org/docs/business/repositories/
所以,我想知道使用 SeedStack 对查询结果进行分页的最佳方法是什么。
【问题讨论】:
标签: java jpa pagination out-of-memory seedstack