I'm developing a REST WebService, and for the data layer I'm using JPA with Hibernate. My application requires many different reports over a lot of data. I believe that querying this data using regular queries (being them JPQL or Native SQL) will take a lot of time. We're talking about many table joins, aggregate functions by month, by district, groups, sums, etc. Only read queries are necessary.
One approach could be using a Materialized View and map the results to JPA entities. However, this would kind of defeat the whole purpose of using an ORM since it wouldn't be database independent. Besides that, it would tightly couple the application and the database structure, which I would like to avoid.
Another approach could be to have the materialized view logic in the application side, using JPA. My first guess is that this isn't easy. For example, I would like to use incrementally refreshable materialized views, and this seems to have a rather complex logic.
What's the recommended way to accomplish this? Is there any particular framework or library that would help achieving this?
If it helps, I'm using Spring Data JPA and of course Spring itself.
Thank you.