【发布时间】:2019-04-15 08:43:58
【问题描述】:
我有很多表,我使用 JPARepository 从中获取数据。然后我在 MySql - View 上创建并尝试使用 JPARepository 来做 findAll 但它不起作用。
【问题讨论】:
标签: mysql spring-data spring-boot-jpa
我有很多表,我使用 JPARepository 从中获取数据。然后我在 MySql - View 上创建并尝试使用 JPARepository 来做 findAll 但它不起作用。
【问题讨论】:
标签: mysql spring-data spring-boot-jpa
您可以使用本机查询和 DTO 投影:
public interface ReportRepository extends JpaRepository<SomeEntity, Long> {
@Query(nativeQuery = true, value = "SELECT * FROM yourView")
List<YourDto> getDateFromYourView();
}
【讨论】: