I have read other threads on here about this subject but none of the solutions work for me.
I tried putting this in my hibernate.cfg.xml:
<property name="hibernate.cache.region.factory_class">org.hibernate.cache.spi.EntityRegion</property>
I always get this error: could not instantiate RegionFactory [org.hibernate.cache.spi.EntityRegion]
I also tried most suggestions from threads on Hibernate websites but no luck.
So how do I configure this?
Well, I found the answer (from a Youtube user):
Update hibernate.cfg.xml
:
<property name="cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</property>
Add slf4j-api-1.6.1.jar (I found it in ehcache-2.5.1-distribution.tar.gz downloaded from ehcache.org in addition) because of ClassNotFoundException.
Add this to your hibernate.cfg.xml:
<!-- Enable Hibernate's automatic session context management -->
<property name="cache.use_second_level_cache">true</property>
The key point here was adding the ehcache jar from the optional\ directory in Hibernate4.