Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有很多表,我使用 JPARepository 从中获取数据。然后我在 MySql - View 上创建并尝试使用 JPARepository 来做 findAll 但它不起作用。
您可以使用本机查询和 DTO 投影:
public interface ReportRepository extends JpaRepository<SomeEntity, Long> { @Query(nativeQuery = true, value = "SELECT * FROM yourView") List<YourDto> getDateFromYourView(); }