Harkamwaljeet Singh
Harkamwaljeet Singh

Reputation: 96

How to enable second level cache in Hibernate 5.2.2?

This post tries to explain how to enable caching in Hibernate 5.2.2 as it requires additional configuration.

Upvotes: 0

Views: 8629

Answers (2)

Pooja Modi
Pooja Modi

Reputation: 1

For properties file

hibernate.cache.use_second_level_cache=true
hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory

Upvotes: 0

Harkamwaljeet Singh
Harkamwaljeet Singh

Reputation: 96

For enabling second level cache in Hibernate 5.2.2, along with setting use_second_level_cache to true, and providing provider class using provider_class. We also need to set the cache.region.factory class.

hibernate.cfg.xml changes below :

    <property name="hibernate.cache.use_second_level_cache">true</property>

    <property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>

    <property name="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</property>

Upvotes: 2

Related Questions