一、普通方式(五种)
参考链接:https://www.bytestree.com/spring/spring-data-jpa-projections-5-ways-return-custom-object/
二、Class-based Projections (DTOs)
除上述5种之外,还有一种Class-based Projections (DTOs),它无需像Argument Constructor方法那样使用JPQL,但是劣势是DTOs的属性为final类型。
参考链接:
https://docs.spring.io/spring-data/jpa/docs/current/reference/html/#projections.dtos
https://www.baeldung.com/spring-data-jpa-projections 章节4