0

I have many tables where I am using JPARepository to fetch data from it. Then I have created on MySql - View and tried to use JPARepository to do findAll but it is not working.

1 Answers1

0

You can use a native query and a DTO projection:

public interface ReportRepository extends JpaRepository<SomeEntity, Long> {

   @Query(nativeQuery = true, value = "SELECT * FROM yourView")
   List<YourDto> getDateFromYourView();

}
Robert Niestroj
  • 15,299
  • 14
  • 76
  • 119