带投影的 Spring Data JPA 自定义存储库

问题描述 投票:0回答:0

我尝试用Projections实现一个查询方法,但我不确定我做的对不对。我是 Spring Boot 世界的新手,不知道如何使用 Projection 创建统计查询。如果你能帮我解决我的问题,我将不胜感激。

实现一个允许以下查询的 TestRepository:- 统计查询 which

  • 号码
  • 每个测试套件类型
  • 每个测试结果
  • 一段时间

公共课预测{ 公共静态记录 TestKitTypeResultCountRecord(TestKitType testKitType, TestResult testResult, Long count) {} }

@存储库 公共接口 TestsRepository 扩展 JpaRepository {

List<Projections.TestKitTypeResultCountRecord> findTestKitTypeResultCountByTestTimeStampBetween(LocalDateTime startDate, LocalDateTime endDate);

}

java spring jpa projection
© www.soinside.com 2019 - 2024. All rights reserved.