We're updating the issue view to help you get more done. 

SessionFactoryOptions#isSecondLevelCacheEnabled returns true by default with NoCachingRegionFactory

Description

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

Environment

None

Status

Assignee

Gail Badner

Reporter

Gail Badner

Components

Fix versions

Affects versions

5.1.13
5.2.15
5.2.16

Priority

Major