Class ActionQueueLegacy

java.lang.Object
org.hibernate.engine.spi.ActionQueueLegacy
All Implemented Interfaces:
ActionQueue, TransactionCompletionCallbacks

public class ActionQueueLegacy extends Object implements ActionQueue
Legacy implementation of the action queue.

The ActionQueueLegacy holds the DML operations queued as part of a session's transactional-write-behind semantics. The DML operations are queued here until a flush forces them to be executed against the database.

This is the legacy implementation. The new, currently incubating, implementation is GraphBasedActionQueue.

API Note:
This class is logically part of the action subsystem and so it would more naturally belong in the package org.hibernate.action.spi. It is located here for purely historical reasons.
  • Constructor Details

    • ActionQueueLegacy

      public ActionQueueLegacy(SessionImplementor session)
      Constructs an action queue bound to the given session.
      Parameters:
      session - The session "owning" this queue.
  • Method Details

    • clear

      public void clear()
      Description copied from interface: ActionQueue
      Clear all pending actions.
      Specified by:
      clear in interface ActionQueue
    • addAction

      public void addAction(org.hibernate.action.internal.EntityInsertAction action)
      Adds an entity insert action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the entity insertion
    • addAction

      public void addAction(org.hibernate.action.internal.EntityIdentityInsertAction action)
      Adds an entity (IDENTITY) insert action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the entity insertion
    • addAction

      public void addAction(org.hibernate.action.internal.EntityDeleteAction action)
      Adds an entity delete action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the entity deletion
    • addAction

      public void addAction(org.hibernate.action.internal.OrphanRemovalAction action)
      Adds an orphan removal action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the orphan removal
    • addAction

      public void addAction(org.hibernate.action.internal.EntityUpdateAction action)
      Adds an entity update action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the entity update
    • addAction

      public void addAction(org.hibernate.action.internal.CollectionRecreateAction action)
      Adds a collection (re)create action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the (re)creation of a collection
    • addAction

      public void addAction(org.hibernate.action.internal.CollectionRemoveAction action)
      Adds a collection remove action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the removal of a collection
    • addAction

      public void addAction(org.hibernate.action.internal.CollectionUpdateAction action)
      Adds a collection update action
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the update of a collection
    • addAction

      public void addAction(org.hibernate.action.internal.QueuedOperationCollectionAction action)
      Adds an action relating to a collection queued operation (extra lazy).
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the queued operation
    • addAction

      public void addAction(org.hibernate.action.internal.BulkOperationCleanupAction action)
      Adds an action defining a cleanup relating to a bulk operation (HQL/JPQL or Criteria based update/delete)
      Specified by:
      addAction in interface ActionQueue
      Parameters:
      action - The action representing the queued operation
    • hasUnresolvedEntityInsertActions

      public boolean hasUnresolvedEntityInsertActions()
      Are there unresolved entity insert actions that depend on non-nullable associations with a transient entity?
      Specified by:
      hasUnresolvedEntityInsertActions in interface ActionQueue
      Returns:
      true, if there are unresolved entity insert actions that depend on non-nullable associations with a transient entity; false, otherwise
    • checkNoUnresolvedActionsAfterOperation

      public void checkNoUnresolvedActionsAfterOperation() throws PropertyValueException
      Throws PropertyValueException if there are any unresolved entity insert actions that depend on non-nullable associations with a transient entity. This method should be called on completion of an operation (after all cascades are completed) that saves an entity.
      Specified by:
      checkNoUnresolvedActionsAfterOperation in interface ActionQueue
      Throws:
      PropertyValueException - if there are any unresolved entity insert actions; PropertyValueException.getEntityName() and PropertyValueException.getPropertyName() will return the entity name and property value for the first unresolved entity insert action.
    • registerCallback

      public void registerCallback(TransactionCompletionCallbacks.BeforeCompletionCallback process)
      Description copied from interface: TransactionCompletionCallbacks
      Register a process (callback) to be performed at the start of transaction completion.
      Specified by:
      registerCallback in interface TransactionCompletionCallbacks
      Parameters:
      process - The callback.
    • registerCallback

      public void registerCallback(TransactionCompletionCallbacks.AfterCompletionCallback process)
      Description copied from interface: TransactionCompletionCallbacks
      Register a process (callback) to be performed at the end of transaction completion.
      Specified by:
      registerCallback in interface TransactionCompletionCallbacks
      Parameters:
      process - The callback.
    • executeInserts

      public void executeInserts() throws HibernateException
      Perform all currently queued entity-insertion actions.
      Specified by:
      executeInserts in interface ActionQueue
      Throws:
      HibernateException - error executing queued insertion actions.
    • executeActions

      public void executeActions() throws HibernateException
      Perform all currently queued actions.
      Specified by:
      executeActions in interface ActionQueue
      Throws:
      HibernateException - error executing queued actions.
    • prepareActions

      public void prepareActions() throws HibernateException
      Prepares the internal action queues for execution.
      Specified by:
      prepareActions in interface ActionQueue
      Throws:
      HibernateException - error preparing actions.
    • afterTransactionCompletion

      public void afterTransactionCompletion(boolean success)
      Performs cleanup of any held cache soft locks.
      Specified by:
      afterTransactionCompletion in interface ActionQueue
      Parameters:
      success - Was the transaction successful.
    • executePendingBulkOperationCleanUpActions

      @Internal public void executePendingBulkOperationCleanUpActions()
      Description copied from interface: ActionQueue
      Execute pending bulk operation cleanup actions.
      Specified by:
      executePendingBulkOperationCleanUpActions in interface ActionQueue
    • beforeTransactionCompletion

      public void beforeTransactionCompletion()
      Execute any registered BeforeTransactionCompletionProcess
      Specified by:
      beforeTransactionCompletion in interface ActionQueue
    • setAuditChangesetContext

      public void setAuditChangesetContext(Object changelog, Session changesetSession)
      Description copied from interface: ActionQueue
      Record the changelog context generated while binding legacy audit mutations.
      Specified by:
      setAuditChangesetContext in interface ActionQueue
      Parameters:
      changelog - The changelog entity instance
      changesetSession - The child session used to persist the changelog entity
    • areInsertionsOrDeletionsQueued

      public boolean areInsertionsOrDeletionsQueued()
      Check whether any insertion or deletion actions are currently queued.
      Specified by:
      areInsertionsOrDeletionsQueued in interface ActionQueue
      Returns:
      true if insertions or deletions are currently queued; false otherwise.
    • areTablesToBeUpdated

      public boolean areTablesToBeUpdated(Set<? extends Serializable> tables)
      Check whether the given tables/query-spaces are to be executed against given the currently queued actions.
      Specified by:
      areTablesToBeUpdated in interface ActionQueue
      Parameters:
      tables - The table/query-spaces to check.
      Returns:
      true if we contain pending actions against any of the given tables; false otherwise.
    • execute

      public <E extends Executable & Comparable<?>> void execute(E executable)
      Parameters:
      executable - The action to execute
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.
    • numberOfCollectionRemovals

      public int numberOfCollectionRemovals()
      Description copied from interface: ActionQueue
      Get the number of collection removals.
      Specified by:
      numberOfCollectionRemovals in interface ActionQueue
      Returns:
      The number of collection removals
    • numberOfCollectionUpdates

      public int numberOfCollectionUpdates()
      Description copied from interface: ActionQueue
      Get the number of collection updates.
      Specified by:
      numberOfCollectionUpdates in interface ActionQueue
      Returns:
      The number of collection updates
    • numberOfCollectionCreations

      public int numberOfCollectionCreations()
      Description copied from interface: ActionQueue
      Get the number of collection creations.
      Specified by:
      numberOfCollectionCreations in interface ActionQueue
      Returns:
      The number of collection creations
    • numberOfDeletions

      public int numberOfDeletions()
      Description copied from interface: ActionQueue
      Get the number of deletions.
      Specified by:
      numberOfDeletions in interface ActionQueue
      Returns:
      The number of deletions
    • numberOfUpdates

      public int numberOfUpdates()
      Description copied from interface: ActionQueue
      Get the number of updates.
      Specified by:
      numberOfUpdates in interface ActionQueue
      Returns:
      The number of updates
    • numberOfInsertions

      public int numberOfInsertions()
      Description copied from interface: ActionQueue
      Get the number of insertions.
      Specified by:
      numberOfInsertions in interface ActionQueue
      Returns:
      The number of insertions
    • getTransactionCompletionCallbacks

      public TransactionCompletionCallbacksImplementor getTransactionCompletionCallbacks()
      Description copied from interface: ActionQueue
      Get the transaction completion callbacks.
      Specified by:
      getTransactionCompletionCallbacks in interface ActionQueue
      Returns:
      The transaction completion callbacks implementor
    • setTransactionCompletionCallbacks

      public void setTransactionCompletionCallbacks(TransactionCompletionCallbacksImplementor callbacks, boolean isTransactionCoordinatorShared)
      Bind transaction completion processes to make them shared between primary and secondary session. Transaction completion processes are always executed by transaction owner (primary session), but can be registered using secondary session too.
      Specified by:
      setTransactionCompletionCallbacks in interface ActionQueue
      Parameters:
      callbacks - Transaction completion callbacks.
      isTransactionCoordinatorShared - Flag indicating shared transaction context.
    • sortCollectionActions

      public void sortCollectionActions()
      Description copied from interface: ActionQueue
      Sort collection actions if ordering is enabled.
      Specified by:
      sortCollectionActions in interface ActionQueue
    • sortActions

      public void sortActions()
      Description copied from interface: ActionQueue
      Sort entity actions if ordering is enabled.
      Specified by:
      sortActions in interface ActionQueue
    • clearFromFlushNeededCheck

      public void clearFromFlushNeededCheck(int previousCollectionRemovalSize)
      Description copied from interface: ActionQueue
      Clear actions that were added during a flush needed check.
      Specified by:
      clearFromFlushNeededCheck in interface ActionQueue
      Parameters:
      previousCollectionRemovalSize - The previous collection removal size
    • hasAfterTransactionActions

      public boolean hasAfterTransactionActions()
      Description copied from interface: ActionQueue
      Check if there are after-transaction actions.
      Specified by:
      hasAfterTransactionActions in interface ActionQueue
      Returns:
      true if there are after-transaction actions
    • hasBeforeTransactionActions

      public boolean hasBeforeTransactionActions()
      Description copied from interface: ActionQueue
      Check if there are before-transaction actions.
      Specified by:
      hasBeforeTransactionActions in interface ActionQueue
      Returns:
      true if there are before-transaction actions
    • hasAnyQueuedActions

      public boolean hasAnyQueuedActions()
      Description copied from interface: ActionQueue
      Check if there are any queued actions.
      Specified by:
      hasAnyQueuedActions in interface ActionQueue
      Returns:
      true if there are any queued actions
    • unScheduleUnloadedDeletion

      public void unScheduleUnloadedDeletion(Object newEntity)
      Description copied from interface: ActionQueue
      Un-schedule a deletion for an unloaded entity.
      Specified by:
      unScheduleUnloadedDeletion in interface ActionQueue
      Parameters:
      newEntity - The entity being persisted
    • unScheduleDeletion

      public void unScheduleDeletion(EntityEntry entry, Object rescuedEntity)
      Description copied from interface: ActionQueue
      Un-schedule a deletion for an entity.
      Specified by:
      unScheduleDeletion in interface ActionQueue
      Parameters:
      entry - The entity entry
      rescuedEntity - The entity being rescued from deletion
    • serialize

      public void serialize(ObjectOutputStream oos) throws IOException
      Used by the owning session to explicitly control serialization of the action queue
      Specified by:
      serialize in interface ActionQueue
      Parameters:
      oos - The stream to which the action queue should get written
      Throws:
      IOException - Indicates an error writing to the stream
      See Also:
    • deserialize

      public static ActionQueueLegacy deserialize(ObjectInputStream ois, EventSource session) throws IOException, ClassNotFoundException
      Used by the owning session to explicitly control deserialization of the action queue.
      Parameters:
      ois - The stream from which to read the action queue
      session - The session to which the action queue belongs
      Returns:
      The deserialized action queue
      Throws:
      IOException - indicates a problem reading from the stream
      ClassNotFoundException - Generally means we were unable to locate user classes.