I'm using hibernate 5.3.3, hibernate-ehcache 5.3.1 & ehcahe 3.2. with Java 8.
I added the following configurations in hibernate.cfg.xml
<property name="cache.use_second_level_cache">true</property>
<property name="cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory
</property>
<property name="hibernate.cache.use_query_cache">true</property>
I added the following annotations in in my entity class as well.
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
I searched on the internet but I did not find any answers for the follwowing exception.
`Caused by: org.hibernate.cache.CacheException: On-the-fly creation of JCache Cache objects is not supported [default-update-timestamps-region]
at org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.createCache(EhcacheRegionFactory.java:106)
at org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.getOrCreateCache(EhcacheRegionFactory.java:100)
at org.hibernate.cache.ehcache.internal.EhcacheRegionFactory.createTimestampsRegionStorageAccess(EhcacheRegionFactory.java:86)
at org.hibernate.cache.spi.support.RegionFactoryTemplate.buildTimestampsRegion(RegionFactoryTemplate.java:70)
at org.hibernate.cache.internal.EnabledCaching.<init>(EnabledCaching.java:80)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:33)
at org.hibernate.engine.spi.CacheInitiator.initiateService(CacheInitiator.java:24)
at org.hibernate.service.spi.SessionFactoryServiceInitiator.initiateService(SessionFactoryServiceInitiator.java:30)
at org.hibernate.service.internal.SessionFactoryServiceRegistryImpl.initiateService(SessionFactoryServiceRegistryImpl.java:68)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263)
... 21 more`
EhCacheRegionFactory is used to connect to Ehcache 2.x. You said you are using Ehcache 3.2, which is good. But it also means you should use a org.hibernate.cache.jcache.JCacheRegionFactory
to configure it.