Hibernate's second-level cache is an application-level storage cache for business data. Question archive is a separate archive that stores only query results.
The two savings are very intertwined because there are not many cases where we would like to use one other. When used correctly, these repositories provide improved performance transparently by reducing the number of SQL statements affecting the database.
The second-tier repository stores business data, but NOT the organizations themselves. The information is stored in a 'waterproof' format that looks like a hash map where the key is a business id, and the value is a list of old values.
Here is an example of what the content of the second paragraph looks like:
1
* --------------------------------------------
2
| Personal Data Storage |
3
| --------------------------------------------- |
4
| 1 -> ["John", "Q", "Public", null] |
5
| 2 -> ["Joey", "D", "Public", 1] |
6
| 3 -> ["Sarah", "N", "Community", 1] |
7
* ---------------------------------------------
The second-tier repository stores business data, but NOT the organizations themselves. The information is stored in a 'waterproof' format that looks like a hash map where the key is a business id, and the value is a list of old values.
The query cache looks like a hash map where the key is the query and the parameter values, and the value of the business ID id is the same as the query:
1
* ----------------------------------------------------- ---- --------- *
2
| Question Cache |
3
| ------------------------------------------------------ --- --------- |
4
| ["from Person where firstName =?", ["Joey"]] -> [1, 2]] |
5
* ----------------------------------------------------- ---- --------- *
Some questions do not return organizations. And instead, it only returns old values. In that case, the numbers themselves will be stored in the query repository.
The query is full when a JPQL / HQL query is created that can be used.