Top Description Fields
org.hibernate.cfg

public Interface CacheSettings

Known Direct Subinterfaces
org.hibernate.cfg.AvailableSettings
Imports
org.hibernate.cache.internal.NoCachingRegionFactory, org.hibernate.cache.spi.RegionFactory, .TimestampsCacheFactory, org.hibernate.jpa.SpecHints

Settings for Hibernate's second-level caching
Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
public static final String
AUTO_EVICT_COLLECTION_CACHE

Enables the automatic eviction of a bidirectional association's collection cache when an element in the jakarta.persistence.ManyToOne collection is added, updated, or removed without properly managing the change on the jakarta.persistence.OneToMany side.

public static final String
public static final String
CACHE_REGION_FACTORY

The RegionFactory implementation, either:

public static final String
CACHE_REGION_PREFIX

The CacheProvider region name prefix

public static final String
CLASS_CACHE_PREFIX

Entity cache configuration properties follow the pattern hibernate.classcache.packagename.ClassName usage[, region] where usage is the cache strategy used and region the cache region name

public static final String
COLLECTION_CACHE_PREFIX

Collection cache configuration properties follow the pattern hibernate.collectioncache.packagename.ClassName.role usage[, region] where usage is the cache strategy used and region the cache region name

public static final String
DEFAULT_CACHE_CONCURRENCY_STRATEGY

Specifies the org.hibernate.annotations.CacheConcurrencyStrategy to use by default when an entity is marked @Cacheable, but no concurrency strategy is explicitly specified via the org.hibernate.annotations.Cache annotation.

public static final String
JAKARTA_SHARED_CACHE_MODE

When enabled, specifies that the second-level cache (which JPA calls the "shared" cache) may be used, as per the rules defined in JPA 2 section 3.1.7.

public static final String
JAKARTA_SHARED_CACHE_RETRIEVE_MODE

Set a default value for SpecHints#HINT_SPEC_CACHE_RETRIEVE_MODE, used when the hint is not explicitly specified.

public static final String
JAKARTA_SHARED_CACHE_STORE_MODE

Set a default value for SpecHints#HINT_SPEC_CACHE_STORE_MODE, used when the hint is not explicitly specified.

public static final String
JPA_SHARED_CACHE_MODE

Used to indicate whether second-level (what JPA terms shared cache) caching is enabled as per the rules defined in JPA 2 section 3.1.7.

public static final String
public static final String
public static final String
public static final String
USE_DIRECT_REFERENCE_CACHE_ENTRIES

Enable direct storage of entity references into the second level cache when applicable.

public static final String
USE_MINIMAL_PUTS

Optimize interaction with the second-level cache to minimize writes, at the cost of an additional read before each write.

public static final String
USE_QUERY_CACHE

Enable the query results cache

public static final String
USE_SECOND_LEVEL_CACHE

When enabled, specifies that the second-level cache may be used.

public static final String
USE_STRUCTURED_CACHE

Enables the use of structured second-level cache entries.

Field Detail

AUTO_EVICT_COLLECTION_CACHEback to summary
public static final String AUTO_EVICT_COLLECTION_CACHE

Enables the automatic eviction of a bidirectional association's collection cache when an element in the jakarta.persistence.ManyToOne collection is added, updated, or removed without properly managing the change on the jakarta.persistence.OneToMany side.

See Also
org.hibernate.boot.SessionFactoryBuilder#applyAutomaticEvictionOfCollectionCaches(boolean)
CACHE_KEYS_FACTORYback to summary
public static final String CACHE_KEYS_FACTORY

Deprecated

this is only honored for hibernate-infinispan

Specifies the org.hibernate.cache.spi.CacheKeysFactory to use, either:

Annotations
@Deprecated
@SuppressWarnings:DeprecatedIsStillUsed
Since
5.2
CACHE_REGION_FACTORYback to summary
public static final String CACHE_REGION_FACTORY

The RegionFactory implementation, either:

Defaults to NoCachingRegionFactory, so that caching is disabled.

See Also
USE_SECOND_LEVEL_CACHE
CACHE_REGION_PREFIXback to summary
public static final String CACHE_REGION_PREFIX

The CacheProvider region name prefix

See Also
org.hibernate.boot.SessionFactoryBuilder#applyCacheRegionPrefix(String)
CLASS_CACHE_PREFIXback to summary
public static final String CLASS_CACHE_PREFIX

Entity cache configuration properties follow the pattern hibernate.classcache.packagename.ClassName usage[, region] where usage is the cache strategy used and region the cache region name

COLLECTION_CACHE_PREFIXback to summary
public static final String COLLECTION_CACHE_PREFIX

Collection cache configuration properties follow the pattern hibernate.collectioncache.packagename.ClassName.role usage[, region] where usage is the cache strategy used and region the cache region name

DEFAULT_CACHE_CONCURRENCY_STRATEGYback to summary
public static final String DEFAULT_CACHE_CONCURRENCY_STRATEGY

Specifies the org.hibernate.annotations.CacheConcurrencyStrategy to use by default when an entity is marked @Cacheable, but no concurrency strategy is explicitly specified via the org.hibernate.annotations.Cache annotation.

An explicit strategy may be specified using @Cache(usage=...).

See Also
org.hibernate.boot.MetadataBuilder#applyAccessType(org.hibernate.cache.spi.access.AccessType), RegionFactory#getDefaultAccessType
JAKARTA_SHARED_CACHE_MODEback to summary
public static final String JAKARTA_SHARED_CACHE_MODE

When enabled, specifies that the second-level cache (which JPA calls the "shared" cache) may be used, as per the rules defined in JPA 2 section 3.1.7.

See JPA 2 sections 9.4.3 and 8.2.1.7

See Also
jakarta.persistence.SharedCacheMode
JAKARTA_SHARED_CACHE_RETRIEVE_MODEback to summary
public static final String JAKARTA_SHARED_CACHE_RETRIEVE_MODE

Set a default value for SpecHints#HINT_SPEC_CACHE_RETRIEVE_MODE, used when the hint is not explicitly specified.

It does not usually make sense to change the default from jakarta.persistence.CacheRetrieveMode#USE.

See Also
SpecHints#HINT_SPEC_CACHE_RETRIEVE_MODE
JAKARTA_SHARED_CACHE_STORE_MODEback to summary
public static final String JAKARTA_SHARED_CACHE_STORE_MODE

Set a default value for SpecHints#HINT_SPEC_CACHE_STORE_MODE, used when the hint is not explicitly specified.

It does not usually make sense to change the default from jakarta.persistence.CacheStoreMode#USE.

See Also
SpecHints#HINT_SPEC_CACHE_RETRIEVE_MODE
JPA_SHARED_CACHE_MODEback to summary
public static final String JPA_SHARED_CACHE_MODE

Deprecated

Use JAKARTA_SHARED_CACHE_MODE instead

Used to indicate whether second-level (what JPA terms shared cache) caching is enabled as per the rules defined in JPA 2 section 3.1.7.

See JPA 2 sections 9.4.3 and 8.2.1.7

Annotations
@Deprecated
@SuppressWarnings:DeprecatedIsStillUsed
See Also
jakarta.persistence.SharedCacheMode
JPA_SHARED_CACHE_RETRIEVE_MODEback to summary
public static final String JPA_SHARED_CACHE_RETRIEVE_MODE

Deprecated

Use JAKARTA_SHARED_CACHE_RETRIEVE_MODE instead

Annotations
@Deprecated
@SuppressWarnings:DeprecatedIsStillUsed
JPA_SHARED_CACHE_STORE_MODEback to summary
public static final String JPA_SHARED_CACHE_STORE_MODE

Deprecated

Use JAKARTA_SHARED_CACHE_STORE_MODE instead

Annotations
@Deprecated
@SuppressWarnings:DeprecatedIsStillUsed
QUERY_CACHE_FACTORYback to summary
public static final String QUERY_CACHE_FACTORY

Specifies the org.hibernate.cache.spi.TimestampsCacheFactory to use.

See Also
org.hibernate.boot.SessionFactoryBuilder#applyTimestampsCacheFactory(TimestampsCacheFactory)
USE_DIRECT_REFERENCE_CACHE_ENTRIESback to summary
public static final String USE_DIRECT_REFERENCE_CACHE_ENTRIES

Enable direct storage of entity references into the second level cache when applicable. This is appropriate only for immutable entities.

By default, entities are always stored in a "disassembled" form, that is, as a tuple of attribute values.

See Also
org.hibernate.boot.SessionFactoryBuilder#applyDirectReferenceCaching(boolean)
USE_MINIMAL_PUTSback to summary
public static final String USE_MINIMAL_PUTS

Optimize interaction with the second-level cache to minimize writes, at the cost of an additional read before each write. This setting is useful if writes to the cache are much more expensive than reads from the cache, for example, if the cache is a distributed cache.

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

See Also
org.hibernate.boot.SessionFactoryBuilder#applyMinimalPutsForCaching(boolean), RegionFactory#isMinimalPutsEnabledByDefault()
USE_QUERY_CACHEback to summary
public static final String USE_QUERY_CACHE

Enable the query results cache

See Also
org.hibernate.boot.SessionFactoryBuilder#applyQueryCacheSupport(boolean)
USE_SECOND_LEVEL_CACHEback to summary
public static final String USE_SECOND_LEVEL_CACHE

When enabled, specifies that the second-level cache may be used.

By default, if the configured RegionFactory is not the org.hibernate.cache.internal.NoCachingRegionFactory, then the second-level cache is enabled. Otherwise, the second-level cache is disabled.

See Also
CACHE_REGION_FACTORY, org.hibernate.boot.SessionFactoryBuilder#applySecondLevelCacheSupport(boolean)
USE_STRUCTURED_CACHEback to summary
public static final String USE_STRUCTURED_CACHE

Enables the use of structured second-level cache entries. This makes the cache entries human-readable, but carries a performance cost.

See Also
org.hibernate.boot.SessionFactoryBuilder#applyStructuredCacheEntries(boolean)