This post tries to explain how to enable caching in Hibernate 5.2.2 as it requires additional configuration.
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>