Package org.hibernate.event.internal
Class DefaultResolveNaturalIdEventListener
- java.lang.Object
-
- org.hibernate.event.internal.AbstractReassociateEventListener
-
- org.hibernate.event.internal.AbstractLockUpgradeEventListener
-
- org.hibernate.event.internal.DefaultResolveNaturalIdEventListener
-
- All Implemented Interfaces:
ResolveNaturalIdEventListener
public class DefaultResolveNaturalIdEventListener extends AbstractLockUpgradeEventListener implements ResolveNaturalIdEventListener
Defines the default load event listeners used by hibernate for loading entities in response to generated load events.
-
-
Constructor Summary
Constructors Constructor Description DefaultResolveNaturalIdEventListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
loadFromDatasource(ResolveNaturalIdEvent event)
Performs the process of loading an entity from the configured underlying datasource.void
onResolveNaturalId(ResolveNaturalIdEvent event)
Handle the given resolve natural id event.protected Object
resolveFromCache(ResolveNaturalIdEvent event)
Attempts to resolve the entity id corresponding to the event's natural id values from the sessionprotected Object
resolveNaturalId(ResolveNaturalIdEvent event)
Coordinates the efforts to load a given entity.-
Methods inherited from class org.hibernate.event.internal.AbstractLockUpgradeEventListener
upgradeLock
-
Methods inherited from class org.hibernate.event.internal.AbstractReassociateEventListener
reassociate
-
-
-
-
Method Detail
-
onResolveNaturalId
public void onResolveNaturalId(ResolveNaturalIdEvent event) throws HibernateException
Description copied from interface:ResolveNaturalIdEventListener
Handle the given resolve natural id event.- Specified by:
onResolveNaturalId
in interfaceResolveNaturalIdEventListener
- Parameters:
event
- The resolve natural id event to be handled.- Throws:
HibernateException
- Indicates a problem resolving natural id to primary key
-
resolveNaturalId
protected Object resolveNaturalId(ResolveNaturalIdEvent event)
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- Returns:
- The loaded entity, or null.
-
resolveFromCache
protected Object resolveFromCache(ResolveNaturalIdEvent event)
Attempts to resolve the entity id corresponding to the event's natural id values from the session- Parameters:
event
- The load event- Returns:
- The entity from the cache, or null.
-
loadFromDatasource
protected Object loadFromDatasource(ResolveNaturalIdEvent event)
Performs the process of loading an entity from the configured underlying datasource.- Parameters:
event
- The load event- Returns:
- The object loaded from the datasource, or null if not found.
-
-