Package org.hibernate

Enum CacheMode

    • Enum Constant Detail

      • NORMAL

        public static final CacheMode NORMAL
        The session may read items from the cache, and add items to the cache as it reads them from the database.
      • IGNORE

        public static final CacheMode IGNORE
        The session will never interact with the cache, except to invalidate cached items when updates occur.
      • GET

        public static final CacheMode GET
        The session may read items from the cache, but will not add items, except to invalidate items when updates occur.
      • PUT

        public static final CacheMode PUT
        The session will never read items from the cache, but will add items to the cache as it reads them from the database. In this mode, the value of the configuration setting "hibernate.cache.use_minimal_puts" determines whether an item is written to the cache when the cache already contains an entry with the same key. Minimal puts should be:
        • disabled for a cache where writes and reads carry a similar cost, as is usually the case for a local in-memory cache, and
        • enabled for a cache where writes are much more expensive than reads, which is usually the case for a distributed cache.

        It's not usually necessary to specify this setting explicitly because, by default, it's set to a sensible value by the second-level cache implementation.

        See Also:
        SessionFactoryBuilder.applyMinimalPutsForCaching(boolean)
    • Method Detail

      • values

        public static CacheMode[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (CacheMode c : CacheMode.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static CacheMode valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • isGetEnabled

        public boolean isGetEnabled()
        Does this cache mode indicate that reads are allowed?
        Returns:
        true if cache reads are allowed; false otherwise.
      • isPutEnabled

        public boolean isPutEnabled()
        Does this cache mode indicate that writes are allowed?
        Returns:
        true if cache writes are allowed; false otherwise.
      • interpretExternalSetting

        public static CacheMode interpretExternalSetting​(String setting)
        Interpret externalized form as an instance of this enumeration.
        Parameters:
        setting - The externalized form.
        Returns:
        The matching enum value.
        Throws:
        MappingException - Indicates the external form was not recognized as a valid enum value.