【发布时间】:2022-02-02 15:34:01
【问题描述】:
我有一个表,其中包含最多 50 行的查找值列表。 目前,我每次都在查询该表以查找效率不高的特定值。 因此,我计划通过使用 findAll 从存储库中一次加载所有值作为列表来优化这一点。
List<CardedList> findAll();
我的问题是 A 类 -> B 类 - 保存此存储库的 B 类。每次A类调用B类都会查询findAll吗?
Class A {
//foreach items in the list call Class B
b.someMethod();
}
Class B {
@Autowired
CardedListRepository cardRepo;
someMethod() {
cardRepo.findAll();
}
}
实现这一目标的最佳方法是什么?
【问题讨论】:
标签: spring-boot java-8 spring-data-jpa