我正在尝试为以下情况确定最佳方法。我的项目中没有几个实体,我在这些实体中应用了Spring Data JPA的一些概念,以便为使用DTO加载实体提供出色的服务,并且在需要时提供维护并不难。
@Entity
class Order {
Long id;
Datetime createdDate;
String note;
List<Item> items;
...
}
@Entity
class Item {
Long id;
Order order;
...
}
当前,我有一个基于规范和可分页类的服务方法来加载对象。
public Page findAll(Specification spec , Pageable pageable) {
return repository.findAll(spec,pageable);
}
此方法运行良好,但是存在一些性能问题。我想在规范和可分页类中使用基于类的投影。你们有使用这种方法的建议或示例吗?
此致
Caique Ferreira