Package org.hibernate

Interface Cache

  • All Superinterfaces:
    Cache
    All Known Subinterfaces:
    CacheImplementor, CacheImplementor

    public interface Cache
    extends Cache
    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).

    • Method Detail

      • getSessionFactory

        SessionFactory getSessionFactory()
        Access to the SessionFactory this Cache is bound to.
        Returns:
        The SessionFactory
      • containsEntity

        boolean containsEntity​(java.lang.Class entityClass,
                               java.io.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 - The entity class.
        identifier - The entity identifier
        Returns:
        True if the underlying cache contains corresponding data; false otherwise.
      • containsEntity

        boolean containsEntity​(java.lang.String entityName,
                               java.io.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 - The entity name.
        identifier - The entity identifier
        Returns:
        True if the underlying cache contains corresponding data; false otherwise.
      • evictEntityData

        void evictEntityData​(java.lang.Class entityClass,
                             java.io.Serializable identifier)
        Evicts the entity data for a particular entity "instance".
        Parameters:
        entityClass - The entity class.
        identifier - The entity identifier
        Since:
        5.3
      • evictEntityData

        void evictEntityData​(java.lang.String entityName,
                             java.io.Serializable identifier)
        Evicts the entity data for a particular entity "instance".
        Parameters:
        entityName - The entity name.
        identifier - The entity identifier
        Since:
        5.3
      • evictEntityData

        void evictEntityData​(java.lang.Class entityClass)
        Evicts all entity data from the given region (i.e. for all entities of type).
        Parameters:
        entityClass - The entity class.
        Since:
        5.3
      • evictEntityData

        void evictEntityData​(java.lang.String entityName)
        Evicts all entity data from the given region (i.e. for all entities of type).
        Parameters:
        entityName - The entity name.
        Since:
        5.3
      • evictEntityData

        void evictEntityData()
        Evict data from all entity regions.
        Since:
        5.3
      • evictNaturalIdData

        void evictNaturalIdData​(java.lang.Class entityClass)
        Evict cached data for the given entity's natural-id
        Parameters:
        entityClass - The entity class.
        Since:
        5.3
      • evictNaturalIdData

        void evictNaturalIdData​(java.lang.String entityName)
        Evict cached data for the given entity's natural-id
        Parameters:
        entityName - The entity name.
        Since:
        5.3
      • evictNaturalIdData

        void evictNaturalIdData()
        Evict cached data for all natural-ids (for all entities)
        Since:
        5.3
      • containsCollection

        boolean containsCollection​(java.lang.String role,
                                   java.io.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 - 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.
      • evictCollectionData

        void evictCollectionData​(java.lang.String role,
                                 java.io.Serializable ownerIdentifier)
        Evicts the cache data for the given identified collection "instance"
        Parameters:
        role - The "collection role" (in form [owner-entity-name].[collection-property-name]).
        ownerIdentifier - The identifier of the owning entity
        Since:
        5.3
      • evictCollectionData

        void evictCollectionData​(java.lang.String role)
        Evicts cached data for the given collection role
        Parameters:
        role - The "collection role" (in form [owner-entity-name].[collection-property-name]).
        Since:
        5.3
      • evictCollectionData

        void evictCollectionData()
        Evict cache data for all collections
        Since:
        5.3
      • containsQuery

        boolean containsQuery​(java.lang.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 - The cache name given to the query.
        Returns:
        True if the underlying cache contains corresponding data; false otherwise.
      • evictDefaultQueryRegion

        void evictDefaultQueryRegion()
        Evicts all cached query results from the default region.
      • evictQueryRegion

        void evictQueryRegion​(java.lang.String regionName)
        Evicts all cached query results under the given name.
        Parameters:
        regionName - The cache name associated to the queries being cached.
      • evictQueryRegions

        void evictQueryRegions()
        Evict data from all query regions.
      • evictRegion

        void evictRegion​(java.lang.String regionName)
        Evict all data from the named cache region
        Since:
        5.3
      • evictAll

        default void evictAll()
        Specified by:
        evictAll in interface Cache
      • evictAllRegions

        default void evictAllRegions()
        Evict data from all cache regions.
      • evictEntity

        @Deprecated
        default void evictEntity​(java.lang.Class entityClass,
                                 java.io.Serializable identifier)
        Deprecated.
        Evicts the entity data for a particular entity "instance".
        Parameters:
        entityClass - The entity class.
        identifier - The entity identifier
      • evictEntity

        @Deprecated
        default void evictEntity​(java.lang.String entityName,
                                 java.io.Serializable identifier)
        Deprecated.
        Evicts the entity data for a particular entity "instance".
        Parameters:
        entityName - The entity name.
        identifier - The entity identifier
      • evictEntityRegion

        @Deprecated
        default void evictEntityRegion​(java.lang.Class entityClass)
        Deprecated.
        Evicts all entity data from the given region (i.e. for all entities of type).
        Parameters:
        entityClass - The entity class.
      • evictEntityRegion

        @Deprecated
        default void evictEntityRegion​(java.lang.String entityName)
        Deprecated.
        Evicts all entity data from the given region (i.e. for all entities of type).
        Parameters:
        entityName - The entity name.
      • evictEntityRegions

        @Deprecated
        default void evictEntityRegions()
        Deprecated.
        Use evictEntityData() instead
        Evict data from all entity regions.
      • evictNaturalIdRegion

        @Deprecated
        default void evictNaturalIdRegion​(java.lang.Class entityClass)
        Deprecated.
        Evicts all naturalId data from the given region (i.e. for all entities of type).
        Parameters:
        entityClass - The entity class.
      • evictNaturalIdRegion

        @Deprecated
        default void evictNaturalIdRegion​(java.lang.String entityName)
        Deprecated.
        Evicts all naturalId data from the given region (i.e. for all entities of type).
        Parameters:
        entityName - The entity name.
      • evictNaturalIdRegions

        @Deprecated
        default void evictNaturalIdRegions()
        Deprecated.
        Evict data from all naturalId regions.
      • evictCollection

        @Deprecated
        default void evictCollection​(java.lang.String role,
                                     java.io.Serializable ownerIdentifier)
        Evicts the cache data for the given identified collection instance.
        Parameters:
        role - The "collection role" (in form [owner-entity-name].[collection-property-name]).
        ownerIdentifier - The identifier of the owning entity
      • evictCollectionRegion

        @Deprecated
        default void evictCollectionRegion​(java.lang.String role)
        Deprecated.
        Evicts all entity data from the given region (i.e. evicts cached data for all of the specified collection role).
        Parameters:
        role - The "collection role" (in form [owner-entity-name].[collection-property-name]).
      • evictCollectionRegions

        @Deprecated
        default void evictCollectionRegions()
        Deprecated.
        Evict data from all collection regions.