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.
Asked
Active
Viewed 45 times
1 Answers
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
-
I will try and update. but Based on your answer new question rise in my mind can we JPA Criteria on Views? – Yogesh Jadhav Apr 15 '19 at 09:28