Uploaded image for project: 'Hibernate ORM'
  1. HHH-12508

SessionFactoryOptions#isSecondLevelCacheEnabled returns true by default with NoCachingRegionFactory

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.13, 5.2.15, 5.2.16
    • Fix Version/s: 5.3.0.CR2, 5.1.14, 5.2.18
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true

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

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: