Class SessionCacheModeThreadLocal


  • public class SessionCacheModeThreadLocal
    extends Object
    A thread local that stores the CacheMode during use of a session. This is intended to replicate the functionality provided by Hibernate 3's org.hibernate.CacheMode.
    Since:
    5.10
    • Constructor Detail

      • SessionCacheModeThreadLocal

        public SessionCacheModeThreadLocal()
    • Method Detail

      • set

        public static void set​(CacheMode mode)
        Set cache mode for Hibernate sessions in current thread
        Parameters:
        mode - cache mode
      • temporarilySetCacheMode

        public static Cleanup temporarilySetCacheMode​(CacheMode cacheMode)
        Temporarily set the CacheMode within a try-with-resources code block. For example:

        try (Cleanup restore = temporarilySetCacheMode(CacheMode.IGNORE)) { performImportInternal(context); }