| When caching is not explicitly enabled or disabled via hibernate.cache.query_cache_factory, SessionFactoryOptionsBuilder#secondLevelCacheEnabled will be set to true by default. As a result, SessionFactory#getSessionFactoryOptions()#isSecondLevelCacheEnabled() will return true, even in cases where NoCachingRegionFactory is the RegionFactory (due to other cache-related settings). This inconsistency can cause problems such as https://issues.jboss.org/browse/WFLY-10260. For example, when debugging StatisticsImpl#getCacheRegionStatistics, I see that sessionFactory.getSessionFactoryOptions().isSecondLevelCacheEnabled() incorrectly returns true, when NoCachingRegionFactory is used. As a result, StatisticsImpl#getCacheRegionStatistics throws IllegalArgumentException Instead of returning {{null}. |