org.hibernate.internal
Class CacheImpl

java.lang.Object
  extended by org.hibernate.internal.CacheImpl
All Implemented Interfaces:
Serializable, Cache, CacheImplementor, Service

public class CacheImpl
extends Object
implements CacheImplementor

See Also:
Serialized Form

Constructor Summary
CacheImpl(SessionFactoryImplementor sessionFactory)
           
 
Method Summary
 void addCacheRegion(String name, Region region)
          Add Region to this Cache scope.
 void close()
          Close all cache regions.
 boolean containsCollection(String role, Serializable ownerIdentifier)
          Determine whether the cache contains data for the given collection.
 boolean containsEntity(Class entityClass, Serializable identifier)
          Determine whether the cache contains data for the given entity "instance".
 boolean containsEntity(String entityName, Serializable identifier)
          Determine whether the cache contains data for the given entity "instance".
 boolean containsQuery(String regionName)
          Determine whether the cache contains data for the given query.
 void evictCollection(String role, Serializable ownerIdentifier)
          Evicts the cache data for the given identified collection instance.
 void evictCollectionRegion(String role)
          Evicts all entity data from the given region (i.e.
 void evictCollectionRegions()
          Evict data from all collection regions.
 void evictDefaultQueryRegion()
          Evicts all cached query results from the default region.
 void evictEntity(Class entityClass, Serializable identifier)
          Evicts the entity data for a particular entity "instance".
 void evictEntity(String entityName, Serializable identifier)
          Evicts the entity data for a particular entity "instance".
 void evictEntityRegion(Class entityClass)
          Evicts all entity data from the given region (i.e.
 void evictEntityRegion(String entityName)
          Evicts all entity data from the given region (i.e.
 void evictEntityRegions()
          Evict data from all entity regions.
 void evictNaturalIdRegion(Class entityClass)
          Evicts all naturalId data from the given region (i.e.
 void evictNaturalIdRegion(String entityName)
          Evicts all naturalId data from the given region (i.e.
 void evictNaturalIdRegions()
          Evict data from all naturalId regions.
 void evictQueries()
          Clean up the default QueryCache.
 void evictQueryRegion(String regionName)
          Evicts all cached query results under the given name.
 void evictQueryRegions()
          Evict data from all query regions.
 Map<String,Region> getAllSecondLevelCacheRegions()
          Get all cache regions, including query cache.
 Region getNaturalIdCacheRegion(String regionName)
          Get natural id cache region by its name.
 QueryCache getQueryCache()
          Get the default QueryCache.
 QueryCache getQueryCache(String regionName)
          Get query cache by region name or create a new one if none exist.
 RegionFactory getRegionFactory()
           
 Region getSecondLevelCacheRegion(String regionName)
          Get second level cache region by its name.
 UpdateTimestampsCache getUpdateTimestampsCache()
          Get UpdateTimestampsCache instance managed by the SessionFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CacheImpl

public CacheImpl(SessionFactoryImplementor sessionFactory)
Method Detail

containsEntity

public boolean containsEntity(Class entityClass,
                              Serializable identifier)
Description copied from interface: Cache
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.

Specified by:
containsEntity in interface Cache
Parameters:
entityClass - The entity class.
identifier - The entity identifier
Returns:
True if the underlying cache contains corresponding data; false otherwise.

containsEntity

public boolean containsEntity(String entityName,
                              Serializable identifier)
Description copied from interface: Cache
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.

Specified by:
containsEntity in interface Cache
Parameters:
entityName - The entity name.
identifier - The entity identifier
Returns:
True if the underlying cache contains corresponding data; false otherwise.

evictEntity

public void evictEntity(Class entityClass,
                        Serializable identifier)
Description copied from interface: Cache
Evicts the entity data for a particular entity "instance".

Specified by:
evictEntity in interface Cache
Parameters:
entityClass - The entity class.
identifier - The entity identifier

evictEntity

public void evictEntity(String entityName,
                        Serializable identifier)
Description copied from interface: Cache
Evicts the entity data for a particular entity "instance".

Specified by:
evictEntity in interface Cache
Parameters:
entityName - The entity name.
identifier - The entity identifier

evictEntityRegion

public void evictEntityRegion(Class entityClass)
Description copied from interface: Cache
Evicts all entity data from the given region (i.e. for all entities of type).

Specified by:
evictEntityRegion in interface Cache
Parameters:
entityClass - The entity class.

evictEntityRegion

public void evictEntityRegion(String entityName)
Description copied from interface: Cache
Evicts all entity data from the given region (i.e. for all entities of type).

Specified by:
evictEntityRegion in interface Cache
Parameters:
entityName - The entity name.

evictEntityRegions

public void evictEntityRegions()
Description copied from interface: Cache
Evict data from all entity regions.

Specified by:
evictEntityRegions in interface Cache

evictNaturalIdRegion

public void evictNaturalIdRegion(Class entityClass)
Description copied from interface: Cache
Evicts all naturalId data from the given region (i.e. for all entities of type).

Specified by:
evictNaturalIdRegion in interface Cache
Parameters:
entityClass - The naturalId class.

evictNaturalIdRegion

public void evictNaturalIdRegion(String entityName)
Description copied from interface: Cache
Evicts all naturalId data from the given region (i.e. for all entities of type).

Specified by:
evictNaturalIdRegion in interface Cache
Parameters:
entityName - The naturalId name.

evictNaturalIdRegions

public void evictNaturalIdRegions()
Description copied from interface: Cache
Evict data from all naturalId regions.

Specified by:
evictNaturalIdRegions in interface Cache

containsCollection

public boolean containsCollection(String role,
                                  Serializable ownerIdentifier)
Description copied from interface: Cache
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.

Specified by:
containsCollection in interface Cache
Parameters:
role - The name of the collection role (in form [owner-entity-name].[collection-property-name]) whose regions should be evicted.
ownerIdentifier - The identifier of the owning entity
Returns:
True if the underlying cache contains corresponding data; false otherwise.

evictCollection

public void evictCollection(String role,
                            Serializable ownerIdentifier)
Description copied from interface: Cache
Evicts the cache data for the given identified collection instance.

Specified by:
evictCollection in interface Cache
Parameters:
role - The "collection role" (in form [owner-entity-name].[collection-property-name]).
ownerIdentifier - The identifier of the owning entity

evictCollectionRegion

public void evictCollectionRegion(String role)
Description copied from interface: Cache
Evicts all entity data from the given region (i.e. evicts cached data for all of the specified collection role).

Specified by:
evictCollectionRegion in interface Cache
Parameters:
role - The "collection role" (in form [owner-entity-name].[collection-property-name]).

evictCollectionRegions

public void evictCollectionRegions()
Description copied from interface: Cache
Evict data from all collection regions.

Specified by:
evictCollectionRegions in interface Cache

containsQuery

public boolean containsQuery(String regionName)
Description copied from interface: Cache
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.

Specified by:
containsQuery in interface Cache
Parameters:
regionName - The cache name given to the query.
Returns:
True if the underlying cache contains corresponding data; false otherwise.

evictDefaultQueryRegion

public void evictDefaultQueryRegion()
Description copied from interface: Cache
Evicts all cached query results from the default region.

Specified by:
evictDefaultQueryRegion in interface Cache

evictQueryRegion

public void evictQueryRegion(String regionName)
Description copied from interface: Cache
Evicts all cached query results under the given name.

Specified by:
evictQueryRegion in interface Cache
Parameters:
regionName - The cache name associated to the queries being cached.

evictQueryRegions

public void evictQueryRegions()
Description copied from interface: Cache
Evict data from all query regions.

Specified by:
evictQueryRegions in interface Cache

close

public void close()
Description copied from interface: CacheImplementor
Close all cache regions.

Specified by:
close in interface CacheImplementor

getQueryCache

public QueryCache getQueryCache()
Description copied from interface: CacheImplementor
Get the default QueryCache.

Specified by:
getQueryCache in interface CacheImplementor

getQueryCache

public QueryCache getQueryCache(String regionName)
                         throws HibernateException
Description copied from interface: CacheImplementor
Get query cache by region name or create a new one if none exist.

If the region name is null, then default query cache region will be returned.

Specified by:
getQueryCache in interface CacheImplementor
Parameters:
regionName - Query cache region name.
Returns:
The QueryCache associated with the region name, or default query cache if the region name is null.
Throws:
HibernateException - HibernateException maybe thrown when the creation of new QueryCache instance.

addCacheRegion

public void addCacheRegion(String name,
                           Region region)
Description copied from interface: CacheImplementor
Add Region to this Cache scope.

Specified by:
addCacheRegion in interface CacheImplementor
Parameters:
name - The region name.
region - The Region instance.

getUpdateTimestampsCache

public UpdateTimestampsCache getUpdateTimestampsCache()
Description copied from interface: CacheImplementor
Get UpdateTimestampsCache instance managed by the SessionFactory.

Specified by:
getUpdateTimestampsCache in interface CacheImplementor

evictQueries

public void evictQueries()
                  throws HibernateException
Description copied from interface: CacheImplementor
Clean up the default QueryCache.

Specified by:
evictQueries in interface CacheImplementor
Throws:
HibernateException

getSecondLevelCacheRegion

public Region getSecondLevelCacheRegion(String regionName)
Description copied from interface: CacheImplementor
Get second level cache region by its name.

Specified by:
getSecondLevelCacheRegion in interface CacheImplementor
Parameters:
regionName - The region name.
Returns:
The second level cache region.

getNaturalIdCacheRegion

public Region getNaturalIdCacheRegion(String regionName)
Description copied from interface: CacheImplementor
Get natural id cache region by its name.

Specified by:
getNaturalIdCacheRegion in interface CacheImplementor
Parameters:
regionName - The region name.
Returns:
The natural id cache region.

getAllSecondLevelCacheRegions

public Map<String,Region> getAllSecondLevelCacheRegions()
Description copied from interface: CacheImplementor
Get all cache regions, including query cache.

Specified by:
getAllSecondLevelCacheRegions in interface CacheImplementor
Returns:
The map contains all cache regions with region name as the key.

getRegionFactory

public RegionFactory getRegionFactory()
Specified by:
getRegionFactory in interface CacheImplementor
Returns:
The RegionFactory


Copyright © 2001-2013 Red Hat, Inc. All Rights Reserved.