is it necessary for query caching region to be same as entity caching region

653 views Asked by At

in my project i have enabled hibernate query caching (using ehcache) and 2nd level entity caching for some of the entities . also in the documentation it is mentioned that query caching does not store the complete entity object and only stores the entity identity. So we should enable 2nd level entity caching as well in order to achieve better performance.

I was wondering if query caching region and entity caching region should be same ? or is it ok for them to be different and still entity will be returned from 2nd level cache if its a result of query cached in query cache? Another question I have is, is it ok to configure different 2nd level cache regions for different entities based on business categorization ?

1

There are 1 answers

3
Vlad Mihalcea On

The query cache uses its own region, just like entities should use individual regions.

This allows you to configure each region based on the cache access patterns.

It does not matter whether the query cache is in one region while the entities being cached are in different regions. If will work just fine.