0

I enabled second level cache in hibernate.

<prop key="hibernate.cache.use_second_level_cache">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>

when get entity with id, this cache work correctly, but when use of criteria query not work.
After searching, I realized that the cache is activated by adding a setCacheable method to the query.

But I have a big problem
There are a lot of criteria queries throughout the project, and on the other hand, the criteria queries are derived from another class in another project, and I don't have access to that external class.

Is there a way to apply this setting to all criteria queries in the entire project by setting it once ?

or123456
  • 2,091
  • 8
  • 28
  • 50

0 Answers0