How to enable second level cache in Hibernate 5?

Hi,

I want to enable the secondary level caching in Hibernate 5.

How to enable second level cache in Hibernate 5?

Thanks

View Answers

April 10, 2017 at 1:49 PM

Hi, Secondary level cache is very important in increasing the performance of Hibernate based applications. It caches the frequently used data in memory and no further database call is made till data is not dirty.

So, in Hibernate 5 you can enable secondary level caching and increase application performance.

You should add following in hibernate.cfg.xml file to enable the caching:

<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>

Check Hibernate 5 tutorials. Thanks









Related Tutorials/Questions & Answers:
Advertisements