Top Description Methods
org.hibernate

public Interface Cache

extends Cache
Known Direct Subinterfaces
org.hibernate.cache.spi.CacheImplementor, org.hibernate.engine.spi.CacheImplementor
Annotations
@SuppressWarnings:UnusedDeclaration
Imports
java.io.Serializable

Provides an API for querying/managing the second level cache regions.

CAUTION: None of these methods respect any isolation or transactional semantics associated with the underlying caches. Specifically, evictions perform an immediate "hard" removal outside any transactions and/or locking scheme(s).

Author
Steve Ebersole

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if the underlying cache contains corresponding data; false otherwise.
containsCollection
(String
The name of the collection role (in form [owner-entity-name].[collection-property-name]) whose regions should be evicted.
role
,
Serializable
The identifier of the owning entity
ownerIdentifier
)

Determine whether the cache contains data for the given collection.

public boolean

Returns:

True if the underlying cache contains corresponding data; false otherwise.
containsEntity
(Class<T>
The entity class.
entityClass
,
Serializable
The entity identifier
identifier
)

Determine whether the cache contains data for the given entity "instance".

public boolean

Returns:

True if the underlying cache contains corresponding data; false otherwise.
containsEntity
(String
The entity name.
entityName
,
Serializable
The entity identifier
identifier
)

Determine whether the cache contains data for the given entity "instance".

public boolean

Returns:

True if the underlying cache contains corresponding data; false otherwise.
containsQuery
(String
The cache name given to the query.
regionName
)

Determine whether the cache contains data for the given query.

public default void
evictAll()

Implements javax.persistence.Cache.evictAll.

Clear the cache.
public default void
evictAllRegions()

Evict data from all cache regions.

public default void
evictCollection(String
The "collection role" (in form [owner-entity-name].[collection-property-name]).
role
,
Serializable
The identifier of the owning entity
ownerIdentifier
)

Evicts the cache data for the given identified collection instance.
public void
evictCollectionData(String
The "collection role" (in form [owner-entity-name].[collection-property-name]).
role
,
Serializable
The identifier of the owning entity
ownerIdentifier
)

Evicts the cache data for the given identified collection "instance"

public void
evictCollectionData(String
The "collection role" (in form [owner-entity-name].[collection-property-name]).
role
)

Evicts cached data for the given collection role

public void
evictCollectionData()

Evict cache data for all collections

public default void
evictCollectionRegion(String
The "collection role" (in form [owner-entity-name].[collection-property-name]).
role
)

Deprecated Use Cache#evictCollectionData(String) instead
Evicts all entity data from the given region (i.e. evicts cached data for all of the specified collection role).
public default void
evictCollectionRegions()

Deprecated Use Cache#evictCollectionData() instead
Evict data from all collection regions.
public void
evictDefaultQueryRegion()

Evicts all cached query results from the default region.

public default void
evictEntity(Class<T>
The entity class.
entityClass
,
Serializable
The entity identifier
identifier
)

Evicts the entity data for a particular entity "instance".
public default void
evictEntity(String
The entity name.
entityName
,
Serializable
The entity identifier
identifier
)

Evicts the entity data for a particular entity "instance".
public void
evictEntityData(Class<T>
The entity class.
entityClass
,
Serializable
The entity identifier
identifier
)

Evicts the entity data for a particular entity "instance".

public void
evictEntityData(String
The entity name.
entityName
,
Serializable
The entity identifier
identifier
)

Evicts the entity data for a particular entity "instance".

public void
evictEntityData(Class<T>
The entity class.
entityClass
)

Evicts all entity data from the given region (i.e. for all entities of type).

public void
evictEntityData(String
The entity name.
entityName
)

Evicts all entity data from the given region (i.e. for all entities of type).

public void
evictEntityData()

Evict data from all entity regions.

public default void
evictEntityRegion(Class<T>
The entity class.
entityClass
)

Deprecated Use Cache#evictEntityData(Class) instead
Evicts all entity data from the given region (i.e. for all entities of type).
public default void
evictEntityRegion(String
The entity name.
entityName
)

Deprecated Use Cache#evictEntityData(String) instead
Evicts all entity data from the given region (i.e. for all entities of type).
public default void
evictEntityRegions()

Deprecated Use Cache#evictEntityData() instead
Evict data from all entity regions.
public void
evictNaturalIdData(Class<T>
The entity class.
entityClass
)

Evict cached data for the given entity's natural-id

public void
evictNaturalIdData(String
The entity name.
entityName
)

Evict cached data for the given entity's natural-id

public void
evictNaturalIdData()

Evict cached data for all natural-ids (for all entities)

public default void
evictNaturalIdRegion(Class<T>
The entity class.
entityClass
)

Deprecated Use Cache#evictNaturalIdData(Class) instead
Evicts all naturalId data from the given region (i.e. for all entities of type).
public default void
evictNaturalIdRegion(String
The entity name.
entityName
)

Deprecated Use Cache#evictNaturalIdData(String) instead
Evicts all naturalId data from the given region (i.e. for all entities of type).
public default void
evictNaturalIdRegions()

Deprecated Use Cache#evictNaturalIdData() instead
Evict data from all naturalId regions.
public void
evictQueryRegion(String
The cache name associated to the queries being cached.
regionName
)

Evicts all cached query results under the given name.

public void
evictQueryRegions()

Evict data from all query regions.

public void
evictRegion(String regionName)

Evict all data from the named cache region

public SessionFactory

Returns:

The SessionFactory
getSessionFactory
()

Deprecated as a consequence of SessionFactory being deprecated.
Access to the SessionFactory this Cache is bound to.
Inherited from javax.persistence.Cache:
containsevictevictunwrap

Method Detail

containsCollectionback to summary
public boolean containsCollection(String role, Serializable ownerIdentifier)

Determine whether the cache contains data for the given collection.

The semantic here is whether the cache contains data visible for the current call context.

Parameters
role:String

The name of the collection role (in form [owner-entity-name].[collection-property-name]) whose regions should be evicted.

ownerIdentifier:Serializable

The identifier of the owning entity

Returns:boolean

True if the underlying cache contains corresponding data; false otherwise.

Annotations
@SuppressWarnings:UnusedDeclaration
containsEntityback to summary
public boolean containsEntity(Class<T> entityClass, Serializable identifier)

Determine whether the cache contains data for the given entity "instance".

The semantic here is whether the cache contains data visible for the current call context.

Parameters
entityClass:Class<T>

The entity class.

identifier:Serializable

The entity identifier

Returns:boolean

True if the underlying cache contains corresponding data; false otherwise.

containsEntityback to summary
public boolean containsEntity(String entityName, Serializable identifier)

Determine whether the cache contains data for the given entity "instance".

The semantic here is whether the cache contains data visible for the current call context.

Parameters
entityName:String

The entity name.

identifier:Serializable

The entity identifier

Returns:boolean

True if the underlying cache contains corresponding data; false otherwise.

containsQueryback to summary
public boolean containsQuery(String regionName)

Determine whether the cache contains data for the given query.

The semantic here is whether the cache contains any data for the given region name since query result caches are not transactionally isolated.

Parameters
regionName:String

The cache name given to the query.

Returns:boolean

True if the underlying cache contains corresponding data; false otherwise.

evictAllback to summary
public default void evictAll()

Implements javax.persistence.Cache.evictAll.

Doc from javax.persistence.Cache.evictAll.

Clear the cache.

API Note

Hibernate impl - we only evict entity data here in keeping with the JPA intent (JPA only defines caching for entity data). For evicting all cache regions (collections, natural-ids and query results), use evictAllRegions instead.

Annotations
@Override
evictAllRegionsback to summary
public default void evictAllRegions()

Evict data from all cache regions.

evictCollectionback to summary
public default void evictCollection(String role, Serializable ownerIdentifier)

Evicts the cache data for the given identified collection instance.

Parameters
role:String

The "collection role" (in form [owner-entity-name].[collection-property-name]).

ownerIdentifier:Serializable

The identifier of the owning entity

Annotations
@Deprecated
evictCollectionDataback to summary
public void evictCollectionData(String role, Serializable ownerIdentifier)

Evicts the cache data for the given identified collection "instance"

Parameters
role:String

The "collection role" (in form [owner-entity-name].[collection-property-name]).

ownerIdentifier:Serializable

The identifier of the owning entity

Since
5.3
evictCollectionDataback to summary
public void evictCollectionData(String role)

Evicts cached data for the given collection role

Parameters
role:String

The "collection role" (in form [owner-entity-name].[collection-property-name]).

Since
5.3
evictCollectionDataback to summary
public void evictCollectionData()

Evict cache data for all collections

Since
5.3
evictCollectionRegionback to summary
public default void evictCollectionRegion(String role)

Deprecated

Use Cache#evictCollectionData(String) instead

Evicts all entity data from the given region (i.e. evicts cached data for all of the specified collection role).

Parameters
role:String

The "collection role" (in form [owner-entity-name].[collection-property-name]).

Annotations
@Deprecated
evictCollectionRegionsback to summary
public default void evictCollectionRegions()

Deprecated

Use Cache#evictCollectionData() instead

Evict data from all collection regions.

Annotations
@Deprecated
evictDefaultQueryRegionback to summary
public void evictDefaultQueryRegion()

Evicts all cached query results from the default region.

evictEntityback to summary
public default void evictEntity(Class<T> entityClass, Serializable identifier)

Evicts the entity data for a particular entity "instance".

Parameters
entityClass:Class<T>

The entity class.

identifier:Serializable

The entity identifier

Annotations
@Deprecated
evictEntityback to summary
public default void evictEntity(String entityName, Serializable identifier)

Evicts the entity data for a particular entity "instance".

Parameters
entityName:String

The entity name.

identifier:Serializable

The entity identifier

Annotations
@Deprecated
evictEntityDataback to summary
public void evictEntityData(Class<T> entityClass, Serializable identifier)

Evicts the entity data for a particular entity "instance".

Parameters
entityClass:Class<T>

The entity class.

identifier:Serializable

The entity identifier

Since
5.3
evictEntityDataback to summary
public void evictEntityData(String entityName, Serializable identifier)

Evicts the entity data for a particular entity "instance".

Parameters
entityName:String

The entity name.

identifier:Serializable

The entity identifier

Since
5.3
evictEntityDataback to summary
public void evictEntityData(Class<T> entityClass)

Evicts all entity data from the given region (i.e. for all entities of type).

Parameters
entityClass:Class<T>

The entity class.

Since
5.3
evictEntityDataback to summary
public void evictEntityData(String entityName)

Evicts all entity data from the given region (i.e. for all entities of type).

Parameters
entityName:String

The entity name.

Since
5.3
evictEntityDataback to summary
public void evictEntityData()

Evict data from all entity regions.

Since
5.3
evictEntityRegionback to summary
public default void evictEntityRegion(Class<T> entityClass)

Deprecated

Use Cache#evictEntityData(Class) instead

Evicts all entity data from the given region (i.e. for all entities of type).

Parameters
entityClass:Class<T>

The entity class.

Annotations
@Deprecated
evictEntityRegionback to summary
public default void evictEntityRegion(String entityName)

Deprecated

Use Cache#evictEntityData(String) instead

Evicts all entity data from the given region (i.e. for all entities of type).

Parameters
entityName:String

The entity name.

Annotations
@Deprecated
evictEntityRegionsback to summary
public default void evictEntityRegions()

Deprecated

Use Cache#evictEntityData() instead

Evict data from all entity regions.

Annotations
@Deprecated
evictNaturalIdDataback to summary
public void evictNaturalIdData(Class<T> entityClass)

Evict cached data for the given entity's natural-id

Parameters
entityClass:Class<T>

The entity class.

Since
5.3
evictNaturalIdDataback to summary
public void evictNaturalIdData(String entityName)

Evict cached data for the given entity's natural-id

Parameters
entityName:String

The entity name.

Since
5.3
evictNaturalIdDataback to summary
public void evictNaturalIdData()

Evict cached data for all natural-ids (for all entities)

Since
5.3
evictNaturalIdRegionback to summary
public default void evictNaturalIdRegion(Class<T> entityClass)

Deprecated

Use Cache#evictNaturalIdData(Class) instead

Evicts all naturalId data from the given region (i.e. for all entities of type).

Parameters
entityClass:Class<T>

The entity class.

Annotations
@Deprecated
evictNaturalIdRegionback to summary
public default void evictNaturalIdRegion(String entityName)

Deprecated

Use Cache#evictNaturalIdData(String) instead

Evicts all naturalId data from the given region (i.e. for all entities of type).

Parameters
entityName:String

The entity name.

Annotations
@Deprecated
evictNaturalIdRegionsback to summary
public default void evictNaturalIdRegions()

Deprecated

Use Cache#evictNaturalIdData() instead

Evict data from all naturalId regions.

Annotations
@Deprecated
evictQueryRegionback to summary
public void evictQueryRegion(String regionName)

Evicts all cached query results under the given name.

Parameters
regionName:String

The cache name associated to the queries being cached.

evictQueryRegionsback to summary
public void evictQueryRegions()

Evict data from all query regions.

evictRegionback to summary
public void evictRegion(String regionName)

Evict all data from the named cache region

Since
5.3
getSessionFactoryback to summary
public SessionFactory getSessionFactory()

Deprecated

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

Access to the SessionFactory this Cache is bound to.

Returns:SessionFactory

The SessionFactory