Top Description Fields Constructors Methods
org.hibernate.cache.internal

public Class DefaultCacheKeysFactory

extends Object
implements CacheKeysFactory
Class Inheritance
All Implemented Interfaces
org.hibernate.cache.spi.CacheKeysFactory
Imports
java.io.Serializable, org.hibernate.cache.spi.CacheKeysFactory, org.hibernate.engine.spi.SessionFactoryImplementor, .SharedSessionContractImplementor, org.hibernate.persister.collection.CollectionPersister, org.hibernate.persister.entity.EntityPersister, org.hibernate.type.Type

Second level cache providers now have the option to use custom key implementations. This was done as the default key implementation is very generic and is quite a large object to allocate in large quantities at runtime. In some extreme cases, for example when the hit ratio is very low, this was making the efficiency penalty vs its benefits tradeoff questionable.

Depending on configuration settings there might be opportunities to use simpler key implementations, for example when multi-tenancy is not being used to avoid the tenant identifier, or when a cache instance is entirely dedicated to a single type to use the primary id only, skipping the role or entity name.

Even with multiple types sharing the same cache, their identifiers could be of the same org.hibernate.type.Type; in this case the cache container could use a single type reference to implement a custom equality function without having to look it up on each equality check: that's a small optimisation but the equality function is often invoked extremely frequently.

Another reason is to make it more convenient to implement custom serialization protocols when the implementation supports clustering.

Author
Sanne Grinovero
Since
5.0
See Also
org.hibernate.type.Type#getHashCode(Object, SessionFactoryImplementor), org.hibernate.type.Type#isEqual(Object, Object)

Field Summary

Modifier and TypeField and Description
public static final DefaultCacheKeysFactory
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
createCollectionKey(Object id, CollectionPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Implements org.hibernate.cache.spi.CacheKeysFactory.createCollectionKey.

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public Object
createEntityKey(Object id, EntityPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Implements org.hibernate.cache.spi.CacheKeysFactory.createEntityKey.

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public Object
public Object
public Object
public Object
public static Object
staticCreateCollectionKey(Object id, CollectionPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public static Object
staticCreateEntityKey(Object id, EntityPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.
public static Object
public static Object
public static Object
public static Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
public static final DefaultCacheKeysFactory INSTANCE
SHORT_NAMEback to summary
public static final String SHORT_NAME

Constructor Detail

DefaultCacheKeysFactoryback to summary
public DefaultCacheKeysFactory()

Method Detail

createCollectionKeyback to summary
public Object createCollectionKey(Object id, CollectionPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Implements org.hibernate.cache.spi.CacheKeysFactory.createCollectionKey.

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Annotations
@Override
createEntityKeyback to summary
public Object createEntityKey(Object id, EntityPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Implements org.hibernate.cache.spi.CacheKeysFactory.createEntityKey.

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

Annotations
@Override
createNaturalIdKeyback to summary
public Object createNaturalIdKey(Object naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session)

Implements org.hibernate.cache.spi.CacheKeysFactory.createNaturalIdKey.

Annotations
@Override
getCollectionIdback to summary
public Object getCollectionId(Object cacheKey)

Implements org.hibernate.cache.spi.CacheKeysFactory.getCollectionId.

Annotations
@Override
getEntityIdback to summary
public Object getEntityId(Object cacheKey)

Implements org.hibernate.cache.spi.CacheKeysFactory.getEntityId.

Annotations
@Override
getNaturalIdValuesback to summary
public Object getNaturalIdValues(Object cacheKey)

Implements org.hibernate.cache.spi.CacheKeysFactory.getNaturalIdValues.

Annotations
@Override
staticCreateCollectionKeyback to summary
public static Object staticCreateCollectionKey(Object id, CollectionPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

staticCreateEntityKeyback to summary
public static Object staticCreateEntityKey(Object id, EntityPersister persister, SessionFactoryImplementor factory, String tenantIdentifier)

Deprecated

as a consequence of SessionFactoryImplementor being deprecated. See corresponding docs for further information.

staticCreateNaturalIdKeyback to summary
public static Object staticCreateNaturalIdKey(Object naturalIdValues, EntityPersister persister, SharedSessionContractImplementor session)
staticGetCollectionIdback to summary
public static Object staticGetCollectionId(Object cacheKey)
staticGetEntityIdback to summary
public static Object staticGetEntityId(Object cacheKey)
staticGetNaturalIdValuesback to summary
public static Object staticGetNaturalIdValues(Object cacheKey)