Package org.hibernate.event.internal
Class DefaultDeleteEventListener
- java.lang.Object
-
- org.hibernate.event.internal.DefaultDeleteEventListener
-
- All Implemented Interfaces:
JpaBootstrapSensitive,DeleteEventListener,CallbackRegistryConsumer
public class DefaultDeleteEventListener extends Object implements DeleteEventListener, CallbackRegistryConsumer, JpaBootstrapSensitive
Defines the default delete event listener used by hibernate for deleting entities from the datastore in response to generated delete events.
-
-
Constructor Summary
Constructors Constructor Description DefaultDeleteEventListener()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcascadeAfterDelete(EventSource session, EntityPersister persister, Object entity, DeleteContext transientEntities)protected voidcascadeBeforeDelete(EventSource session, EntityPersister persister, Object entity, DeleteContext transientEntities)protected voiddeleteEntity(EventSource session, Object entity, EntityEntry entityEntry, boolean isCascadeDeleteEnabled, boolean isOrphanRemovalBeforeUpdates, EntityPersister persister, DeleteContext transientEntities)Perform the entity deletion.protected voiddeleteTransientEntity(EventSource session, Object entity, EntityPersister persister, DeleteContext transientEntities)We encountered a delete request on a transient instance.voidinjectCallbackRegistry(CallbackRegistry callbackRegistry)Injection of the CallbackRegistryprotected booleaninvokeDeleteLifecycle(EventSource session, Object entity, EntityPersister persister)voidonDelete(DeleteEvent event)Handle the given delete event.voidonDelete(DeleteEvent event, DeleteContext transientEntities)Handle the given delete event.protected voidperformDetachedEntityDeletionCheck(DeleteEvent event)Called when we have recognized an attempt to delete a detached entity.voidwasJpaBootstrap(boolean wasJpaBootstrap)
-
-
-
Method Detail
-
injectCallbackRegistry
public void injectCallbackRegistry(CallbackRegistry callbackRegistry)
Description copied from interface:CallbackRegistryConsumerInjection of the CallbackRegistry- Specified by:
injectCallbackRegistryin interfaceCallbackRegistryConsumer- Parameters:
callbackRegistry- The CallbackRegistry
-
wasJpaBootstrap
public void wasJpaBootstrap(boolean wasJpaBootstrap)
- Specified by:
wasJpaBootstrapin interfaceJpaBootstrapSensitive
-
onDelete
public void onDelete(DeleteEvent event) throws HibernateException
Handle the given delete event.- Specified by:
onDeletein interfaceDeleteEventListener- Parameters:
event- The delete event to be handled.- Throws:
HibernateException
-
onDelete
public void onDelete(DeleteEvent event, DeleteContext transientEntities) throws HibernateException
Handle the given delete event. This is the cascaded form.- Specified by:
onDeletein interfaceDeleteEventListener- Parameters:
event- The delete event.transientEntities- The cache of entities already deleted- Throws:
HibernateException
-
performDetachedEntityDeletionCheck
protected void performDetachedEntityDeletionCheck(DeleteEvent event)
Called when we have recognized an attempt to delete a detached entity.This is perfectly valid in Hibernate usage; JPA, however, forbids this. Thus, this is a hook for HEM to affect this behavior.
- Parameters:
event- The event.
-
deleteTransientEntity
protected void deleteTransientEntity(EventSource session, Object entity, EntityPersister persister, DeleteContext transientEntities)
We encountered a delete request on a transient instance.This is a deviation from historical Hibernate (pre-3.2) behavior to align with the JPA spec, which states that transient entities can be passed to remove operation in which case cascades still need to be performed.
- Parameters:
session- The session which is the source of the evententity- The entity being delete processedpersister- The entity persistertransientEntities- A cache of already visited transient entities (to avoid infinite recursion).
-
deleteEntity
protected final void deleteEntity(EventSource session, Object entity, EntityEntry entityEntry, boolean isCascadeDeleteEnabled, boolean isOrphanRemovalBeforeUpdates, EntityPersister persister, DeleteContext transientEntities)
Perform the entity deletion. Well, as with most operations, does not really perform it; just schedules an action/execution with theActionQueuefor execution during flush.- Parameters:
session- The originating sessionentity- The entity to deleteentityEntry- The entity's entry in thePersistenceContextisCascadeDeleteEnabled- Is delete cascading enabled?persister- The entity persister.transientEntities- A cache of already deleted entities.
-
invokeDeleteLifecycle
protected boolean invokeDeleteLifecycle(EventSource session, Object entity, EntityPersister persister)
-
cascadeBeforeDelete
protected void cascadeBeforeDelete(EventSource session, EntityPersister persister, Object entity, DeleteContext transientEntities) throws HibernateException
- Throws:
HibernateException
-
cascadeAfterDelete
protected void cascadeAfterDelete(EventSource session, EntityPersister persister, Object entity, DeleteContext transientEntities) throws HibernateException
- Throws:
HibernateException
-
-