public class

DefaultLoadEventListener

extends AbstractLockUpgradeEventListener
implements LoadEventListener
java.lang.Object
   ↳ org.hibernate.event.def.AbstractReassociateEventListener
     ↳ org.hibernate.event.def.AbstractLockUpgradeEventListener
       ↳ org.hibernate.event.def.DefaultLoadEventListener

Class Overview

Defines the default load event listeners used by hibernate for loading entities in response to generated load events.

Summary

Fields
public static final LockMode DEFAULT_LOCK_MODE
public static final Object INCONSISTENT_RTN_CLASS_MARKER
public static final Object REMOVED_ENTITY_MARKER
[Expand]
Inherited Fields
From interface org.hibernate.event.LoadEventListener
Public Constructors
DefaultLoadEventListener()
Public Methods
void onLoad(LoadEvent event, LoadEventListener.LoadType loadType)
Handle the given load event.
Protected Methods
Object doLoad(LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)
Coordinates the efforts to load a given entity.
Object load(LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)
Perfoms the load of an entity.
Object loadFromDatasource(LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)
Performs the process of loading an entity from the configured underlying datasource.
Object loadFromSecondLevelCache(LoadEvent event, EntityPersister persister, LoadEventListener.LoadType options)
Attempts to load the entity from the second-level cache.
Object loadFromSessionCache(LoadEvent event, EntityKey keyToLoad, LoadEventListener.LoadType options)
Attempts to locate the entity in the session-level cache.
Object lockAndLoad(LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options, SessionImplementor source)
If the class to be loaded has been configured with a cache, then lock given id in that cache and then perform the load.
Object proxyOrLoad(LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)
Based on configured options, will either return a pre-existing proxy, generate a new proxy, or perform an actual load.
[Expand]
Inherited Methods
From class org.hibernate.event.def.AbstractLockUpgradeEventListener
From class org.hibernate.event.def.AbstractReassociateEventListener
From class java.lang.Object
From interface org.hibernate.event.LoadEventListener

Fields

public static final LockMode DEFAULT_LOCK_MODE

public static final Object INCONSISTENT_RTN_CLASS_MARKER

public static final Object REMOVED_ENTITY_MARKER

Public Constructors

public DefaultLoadEventListener ()

Public Methods

public void onLoad (LoadEvent event, LoadEventListener.LoadType loadType)

Handle the given load event.

Parameters
event The load event to be handled.
Returns
  • The result (i.e., the loaded entity).

Protected Methods

protected Object doLoad (LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)

Coordinates the efforts to load a given entity. First, an attempt is made to load the entity from the session-level cache. If not found there, an attempt is made to locate it in second-level cache. Lastly, an attempt is made to load it directly from the datasource.

Parameters
event The load event
persister The persister for the entity being requested for load
keyToLoad The EntityKey representing the entity to be loaded.
options The load options.
Returns
  • The loaded entity, or null.

protected Object load (LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)

Perfoms the load of an entity.

Parameters
event The initiating load request event
persister The persister corresponding to the entity to be loaded
keyToLoad The key of the entity to be loaded
options The defined load options
Returns
  • The loaded entity.

protected Object loadFromDatasource (LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)

Performs the process of loading an entity from the configured underlying datasource.

Parameters
event The load event
persister The persister for the entity being requested for load
keyToLoad The EntityKey representing the entity to be loaded.
options The load options.
Returns
  • The object loaded from the datasource, or null if not found.

protected Object loadFromSecondLevelCache (LoadEvent event, EntityPersister persister, LoadEventListener.LoadType options)

Attempts to load the entity from the second-level cache.

Parameters
event The load event
persister The persister for the entity being requested for load
options The load options.
Returns
  • The entity from the second-level cache, or null.

protected Object loadFromSessionCache (LoadEvent event, EntityKey keyToLoad, LoadEventListener.LoadType options)

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 set to true, then if the entity is found in the session-level cache, it's current status within the session cache is checked to see if it has previously been scheduled for deletion.

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

protected Object lockAndLoad (LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options, SessionImplementor source)

If the class to be loaded has been configured with a cache, then lock given id in that cache and then perform the load.

Parameters
event The initiating load request event
persister The persister corresponding to the entity to be loaded
keyToLoad The key of the entity to be loaded
options The defined load options
source The originating session
Returns
  • The loaded entity

protected Object proxyOrLoad (LoadEvent event, EntityPersister persister, EntityKey keyToLoad, LoadEventListener.LoadType options)

Based on configured options, will either return a pre-existing proxy, generate a new proxy, or perform an actual load.

Parameters
event The initiating load request event
persister The persister corresponding to the entity to be loaded
keyToLoad The key of the entity to be loaded
options The defined load options
Returns
  • The result of the proxy/load operation.