Class DefaultReactiveDeleteEventListener

  • All Implemented Interfaces:
    java.io.Serializable, org.hibernate.event.service.spi.JpaBootstrapSensitive, org.hibernate.event.spi.DeleteEventListener, org.hibernate.jpa.event.spi.CallbackRegistryConsumer, ReactiveDeleteEventListener

    public class DefaultReactiveDeleteEventListener
    extends java.lang.Object
    implements org.hibernate.event.spi.DeleteEventListener, ReactiveDeleteEventListener, org.hibernate.jpa.event.spi.CallbackRegistryConsumer, org.hibernate.event.service.spi.JpaBootstrapSensitive
    A reactive DefaultDeleteEventListener.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      protected java.util.concurrent.CompletionStage<java.lang.Void> cascadeAfterDelete​(org.hibernate.event.spi.EventSource session, org.hibernate.persister.entity.EntityPersister persister, java.lang.Object entity, org.hibernate.event.spi.DeleteContext transientEntities)  
      protected java.util.concurrent.CompletionStage<java.lang.Void> cascadeBeforeDelete​(org.hibernate.event.spi.EventSource session, org.hibernate.persister.entity.EntityPersister persister, java.lang.Object entity, org.hibernate.event.spi.DeleteContext transientEntities)  
      protected java.util.concurrent.CompletionStage<java.lang.Void> deleteEntity​(org.hibernate.event.spi.EventSource session, java.lang.Object entity, org.hibernate.engine.spi.EntityEntry entityEntry, boolean isCascadeDeleteEnabled, boolean isOrphanRemovalBeforeUpdates, org.hibernate.persister.entity.EntityPersister persister, org.hibernate.event.spi.DeleteContext transientEntities)
      Perform the entity deletion.
      protected java.util.concurrent.CompletionStage<java.lang.Void> deleteTransientEntity​(org.hibernate.event.spi.EventSource session, java.lang.Object entity, org.hibernate.persister.entity.EntityPersister persister, org.hibernate.event.spi.DeleteContext transientEntities)
      We encountered a delete request on a transient instance.
      void injectCallbackRegistry​(org.hibernate.jpa.event.spi.CallbackRegistry callbackRegistry)  
      void onDelete​(org.hibernate.event.spi.DeleteEvent event)
      Deprecated.
      only the reactive version is supported
      void onDelete​(org.hibernate.event.spi.DeleteEvent event, org.hibernate.event.spi.DeleteContext transientEntities)
      Deprecated.
      only the reactive version is supported
      protected void performDetachedEntityDeletionCheck​(org.hibernate.event.spi.DeleteEvent event)
      Called when we have recognized an attempt to delete a detached entity.
      java.util.concurrent.CompletionStage<java.lang.Void> reactiveOnDelete​(org.hibernate.event.spi.DeleteEvent event)
      Handle the given delete event.
      java.util.concurrent.CompletionStage<java.lang.Void> reactiveOnDelete​(org.hibernate.event.spi.DeleteEvent event, org.hibernate.event.spi.DeleteContext transientEntities)
      Handle the given delete event.
      void wasJpaBootstrap​(boolean wasJpaBootstrap)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultReactiveDeleteEventListener

        public DefaultReactiveDeleteEventListener()
    • Method Detail

      • injectCallbackRegistry

        public void injectCallbackRegistry​(org.hibernate.jpa.event.spi.CallbackRegistry callbackRegistry)
        Specified by:
        injectCallbackRegistry in interface org.hibernate.jpa.event.spi.CallbackRegistryConsumer
      • wasJpaBootstrap

        public void wasJpaBootstrap​(boolean wasJpaBootstrap)
        Specified by:
        wasJpaBootstrap in interface org.hibernate.event.service.spi.JpaBootstrapSensitive
      • onDelete

        @Deprecated
        public void onDelete​(org.hibernate.event.spi.DeleteEvent event)
        Deprecated.
        only the reactive version is supported
        Handle the given delete event.
        Specified by:
        onDelete in interface org.hibernate.event.spi.DeleteEventListener
        Parameters:
        event - The delete event to be handled.
        See Also:
        reactiveOnDelete(DeleteEvent)
      • onDelete

        @Deprecated
        public void onDelete​(org.hibernate.event.spi.DeleteEvent event,
                             org.hibernate.event.spi.DeleteContext transientEntities)
                      throws org.hibernate.HibernateException
        Deprecated.
        only the reactive version is supported
        Specified by:
        onDelete in interface org.hibernate.event.spi.DeleteEventListener
        Throws:
        org.hibernate.HibernateException
        See Also:
        reactiveOnDelete(DeleteEvent, DeleteContext)
      • reactiveOnDelete

        public java.util.concurrent.CompletionStage<java.lang.Void> reactiveOnDelete​(org.hibernate.event.spi.DeleteEvent event)
                                                                              throws org.hibernate.HibernateException
        Handle the given delete event.
        Specified by:
        reactiveOnDelete in interface ReactiveDeleteEventListener
        Parameters:
        event - The delete event to be handled.
        Throws:
        org.hibernate.HibernateException
      • reactiveOnDelete

        public java.util.concurrent.CompletionStage<java.lang.Void> reactiveOnDelete​(org.hibernate.event.spi.DeleteEvent event,
                                                                                     org.hibernate.event.spi.DeleteContext transientEntities)
                                                                              throws org.hibernate.HibernateException
        Handle the given delete event. This is the cascaded form.
        Specified by:
        reactiveOnDelete in interface ReactiveDeleteEventListener
        Parameters:
        event - The delete event.
        transientEntities - The cache of entities already deleted
        Throws:
        org.hibernate.HibernateException
      • performDetachedEntityDeletionCheck

        protected void performDetachedEntityDeletionCheck​(org.hibernate.event.spi.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 java.util.concurrent.CompletionStage<java.lang.Void> deleteTransientEntity​(org.hibernate.event.spi.EventSource session,
                                                                                             java.lang.Object entity,
                                                                                             org.hibernate.persister.entity.EntityPersister persister,
                                                                                             org.hibernate.event.spi.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 event
        entity - The entity being delete processed
        persister - The entity persister
        transientEntities - A cache of already visited transient entities (to avoid infinite recursion).
      • deleteEntity

        protected java.util.concurrent.CompletionStage<java.lang.Void> deleteEntity​(org.hibernate.event.spi.EventSource session,
                                                                                    java.lang.Object entity,
                                                                                    org.hibernate.engine.spi.EntityEntry entityEntry,
                                                                                    boolean isCascadeDeleteEnabled,
                                                                                    boolean isOrphanRemovalBeforeUpdates,
                                                                                    org.hibernate.persister.entity.EntityPersister persister,
                                                                                    org.hibernate.event.spi.DeleteContext transientEntities)
        Perform the entity deletion. Well, as with most operations, does not really perform it; just schedules an action/execution with the ActionQueue for execution during flush.
        Parameters:
        session - The originating session
        entity - The entity to delete
        entityEntry - The entity's entry in the PersistenceContext
        isCascadeDeleteEnabled - Is delete cascading enabled?
        persister - The entity persister.
        transientEntities - A cache of already deleted entities.
      • cascadeBeforeDelete

        protected java.util.concurrent.CompletionStage<java.lang.Void> cascadeBeforeDelete​(org.hibernate.event.spi.EventSource session,
                                                                                           org.hibernate.persister.entity.EntityPersister persister,
                                                                                           java.lang.Object entity,
                                                                                           org.hibernate.event.spi.DeleteContext transientEntities)
                                                                                    throws org.hibernate.HibernateException
        Throws:
        org.hibernate.HibernateException
      • cascadeAfterDelete

        protected java.util.concurrent.CompletionStage<java.lang.Void> cascadeAfterDelete​(org.hibernate.event.spi.EventSource session,
                                                                                          org.hibernate.persister.entity.EntityPersister persister,
                                                                                          java.lang.Object entity,
                                                                                          org.hibernate.event.spi.DeleteContext transientEntities)
                                                                                   throws org.hibernate.HibernateException
        Throws:
        org.hibernate.HibernateException