I have a project which has a dashboard page. within that dashboard page, I have to show :
- Statistic Charts
- New information
- New user suggestions for the admin
- Number of new messages
- ETC
Now each of the above info are related to different tables within my database.
I have created different Entities and I'm using hibernate. Suppose client-A opens his dashboard, I should execute multiple queries for gathering all the info from all of those entities. Here are the challenges:
- Since each request runs in one thread at a time within my program, each queries must be finish for the other query to run (it's not simultaneously)
- We can not create multiple queries at once and map into different entities in hibernate
- The @Formula annotation can not map whole entity and just map single data type
I was thinking the best approach for having an efficient and fast output is to create one Big Native query and get all data at once with a Single query BUT if I'm gonna do this, I have to write native query and map everything by myself which makes the sole of using hibernate faint.
The other approach I'm thinking is to use executor service and multi-threading in my application
Now my question is, what is the best approach that I still can use hibernate mapping and issue high performance query ?
Thank you in advance