Class CacheLoadHelper

java.lang.Object
org.hibernate.loader.internal.CacheLoadHelper

public class CacheLoadHelper extends Object
Some logic which originally resided in DefaultLoadEventListener and in DefaultInitializeCollectionEventListener but was moved here to make it reusable.
  • Method Details

    • loadFromSessionCache

      public static CacheLoadHelper.PersistenceContextEntry loadFromSessionCache(EntityKey keyToLoad, LockOptions lockOptions, LoadEventListener.LoadType options, SharedSessionContractImplementor session)
      Attempts to locate the entity in the session-level cache.

      If allowed to return nulls, then if the entity happens to be found in the session cache, we check the entity type for proper handling of entity hierarchies.

      If checkDeleted was true, and if the entity is found in the session-level cache, its current status within the session cache is checked to see if it has previously been scheduled for deletion.

      Parameters:
      keyToLoad - The EntityKey representing the entity to be loaded
      lockOptions - The lock options
      options - The load options
      session - The originating session
      Returns:
      The entity from the session-level cache, or null.
      Throws:
      HibernateException - Generally indicates problems applying a lock mode.
    • entityStatus

    • loadFromSecondLevelCache

      public static Object loadFromSecondLevelCache(SharedSessionContractImplementor source, Object entity, LockMode lockMode, EntityPersister persister, EntityKey entityKey)
      Attempts to load the entity from the second-level cache.
      Parameters:
      source - The source
      entity - The entity
      lockMode - The lock mode
      persister - The persister for the entity being requested for load
      entityKey - The entity key
      Returns:
      The entity from the second-level cache, or null.
    • initializeCollectionFromCache

      public static boolean initializeCollectionFromCache(Object key, CollectionPersister persister, PersistentCollection<?> collection, SharedSessionContractImplementor source)
      Try to initialize a collection from the cache
      Parameters:
      key - The key of the collection to initialize
      persister - The collection persister
      collection - The collection to initialize
      source - The originating session
      Returns:
      true if we were able to initialize the collection from the cache; false otherwise.