Class ActionQueueLegacy
java.lang.Object
org.hibernate.engine.spi.ActionQueueLegacy
- All Implemented Interfaces:
ActionQueue, TransactionCompletionCallbacks
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classOrder theinsertionsqueue such that we group inserts against the same entity together (without violating constraints).Nested classes/interfaces inherited from interface TransactionCompletionCallbacks
TransactionCompletionCallbacks.AfterCompletionCallback, TransactionCompletionCallbacks.BeforeCompletionCallback, TransactionCompletionCallbacks.CompletionCallback -
Constructor Summary
ConstructorsConstructorDescriptionActionQueueLegacy(SessionImplementor session) Constructs an action queue bound to the given session. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(org.hibernate.action.internal.BulkOperationCleanupAction action) Adds an action defining a cleanup relating to a bulk operation (HQL/JPQL or Criteria based update/delete)voidaddAction(org.hibernate.action.internal.CollectionRecreateAction action) Adds a collection (re)create actionvoidaddAction(org.hibernate.action.internal.CollectionRemoveAction action) Adds a collection remove actionvoidaddAction(org.hibernate.action.internal.CollectionUpdateAction action) Adds a collection update actionvoidaddAction(org.hibernate.action.internal.EntityDeleteAction action) Adds an entity delete actionvoidaddAction(org.hibernate.action.internal.EntityIdentityInsertAction action) Adds an entity (IDENTITY) insert actionvoidaddAction(org.hibernate.action.internal.EntityInsertAction action) Adds an entity insert actionvoidaddAction(org.hibernate.action.internal.EntityUpdateAction action) Adds an entity update actionvoidaddAction(org.hibernate.action.internal.OrphanRemovalAction action) Adds an orphan removal actionvoidaddAction(org.hibernate.action.internal.QueuedOperationCollectionAction action) Adds an action relating to a collection queued operation (extra lazy).voidafterTransactionCompletion(boolean success) Performs cleanup of any held cache soft locks.booleanCheck whether any insertion or deletion actions are currently queued.booleanareTablesToBeUpdated(Set<? extends Serializable> tables) Check whether the given tables/query-spaces are to be executed against given the currently queued actions.voidExecute any registeredBeforeTransactionCompletionProcessvoidThrowsPropertyValueExceptionif there are any unresolved entity insert actions that depend on non-nullable associations with a transient entity.voidclear()Clear all pending actions.voidclearFromFlushNeededCheck(int previousCollectionRemovalSize) Clear actions that were added during a flush needed check.static ActionQueueLegacydeserialize(ObjectInputStream ois, EventSource session) Used by the owning session to explicitly control deserialization of the action queue.<E extends Executable & Comparable<?>>
voidexecute(E executable) voidPerform all currently queued actions.voidPerform all currently queued entity-insertion actions.voidExecute pending bulk operation cleanup actions.Get the transaction completion callbacks.booleanCheck if there are after-transaction actions.booleanCheck if there are any queued actions.booleanCheck if there are before-transaction actions.booleanAre there unresolved entity insert actions that depend on non-nullable associations with a transient entity?intGet the number of collection creations.intGet the number of collection removals.intGet the number of collection updates.intGet the number of deletions.intGet the number of insertions.intGet the number of updates.voidPrepares the internal action queues for execution.voidRegister aprocess(callback) to be performed at the end of transaction completion.voidRegister aprocess(callback) to be performed at the start of transaction completion.voidUsed by the owning session to explicitly control serialization of the action queuevoidsetAuditChangesetContext(Object changelog, Session changesetSession) Record the changelog context generated while binding legacy audit mutations.voidsetTransactionCompletionCallbacks(TransactionCompletionCallbacksImplementor callbacks, boolean isTransactionCoordinatorShared) Bind transaction completion processes to make them shared between primary and secondary session.voidSort entity actions if ordering is enabled.voidSort collection actions if ordering is enabled.toString()Returns a string representation of the object.voidunScheduleDeletion(EntityEntry entry, Object rescuedEntity) Un-schedule a deletion for an entity.voidunScheduleUnloadedDeletion(Object newEntity) Un-schedule a deletion for an unloaded entity.
-
Constructor Details
-
ActionQueueLegacy
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:ActionQueueClear all pending actions.- Specified by:
clearin interfaceActionQueue
-
addAction
public void addAction(org.hibernate.action.internal.EntityInsertAction action) Adds an entity insert action- Specified by:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
addActionin interfaceActionQueue- 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:
hasUnresolvedEntityInsertActionsin interfaceActionQueue- Returns:
- true, if there are unresolved entity insert actions that depend on non-nullable associations with a transient entity; false, otherwise
-
checkNoUnresolvedActionsAfterOperation
ThrowsPropertyValueExceptionif 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:
checkNoUnresolvedActionsAfterOperationin interfaceActionQueue- Throws:
PropertyValueException- if there are any unresolved entity insert actions;PropertyValueException.getEntityName()andPropertyValueException.getPropertyName()will return the entity name and property value for the first unresolved entity insert action.
-
registerCallback
Description copied from interface:TransactionCompletionCallbacksRegister aprocess(callback) to be performed at the start of transaction completion.- Specified by:
registerCallbackin interfaceTransactionCompletionCallbacks- Parameters:
process- The callback.
-
registerCallback
Description copied from interface:TransactionCompletionCallbacksRegister aprocess(callback) to be performed at the end of transaction completion.- Specified by:
registerCallbackin interfaceTransactionCompletionCallbacks- Parameters:
process- The callback.
-
executeInserts
Perform all currently queued entity-insertion actions.- Specified by:
executeInsertsin interfaceActionQueue- Throws:
HibernateException- error executing queued insertion actions.
-
executeActions
Perform all currently queued actions.- Specified by:
executeActionsin interfaceActionQueue- Throws:
HibernateException- error executing queued actions.
-
prepareActions
Prepares the internal action queues for execution.- Specified by:
prepareActionsin interfaceActionQueue- Throws:
HibernateException- error preparing actions.
-
afterTransactionCompletion
public void afterTransactionCompletion(boolean success) Performs cleanup of any held cache soft locks.- Specified by:
afterTransactionCompletionin interfaceActionQueue- Parameters:
success- Was the transaction successful.
-
executePendingBulkOperationCleanUpActions
Description copied from interface:ActionQueueExecute pending bulk operation cleanup actions.- Specified by:
executePendingBulkOperationCleanUpActionsin interfaceActionQueue
-
beforeTransactionCompletion
public void beforeTransactionCompletion()Execute any registeredBeforeTransactionCompletionProcess- Specified by:
beforeTransactionCompletionin interfaceActionQueue
-
setAuditChangesetContext
Description copied from interface:ActionQueueRecord the changelog context generated while binding legacy audit mutations.- Specified by:
setAuditChangesetContextin interfaceActionQueue- Parameters:
changelog- The changelog entity instancechangesetSession- 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:
areInsertionsOrDeletionsQueuedin interfaceActionQueue- Returns:
trueif insertions or deletions are currently queued;falseotherwise.
-
areTablesToBeUpdated
Check whether the given tables/query-spaces are to be executed against given the currently queued actions.- Specified by:
areTablesToBeUpdatedin interfaceActionQueue- Parameters:
tables- The table/query-spaces to check.- Returns:
trueif we contain pending actions against any of the given tables;falseotherwise.
-
execute
- Parameters:
executable- The action to execute
-
toString
-
numberOfCollectionRemovals
public int numberOfCollectionRemovals()Description copied from interface:ActionQueueGet the number of collection removals.- Specified by:
numberOfCollectionRemovalsin interfaceActionQueue- Returns:
- The number of collection removals
-
numberOfCollectionUpdates
public int numberOfCollectionUpdates()Description copied from interface:ActionQueueGet the number of collection updates.- Specified by:
numberOfCollectionUpdatesin interfaceActionQueue- Returns:
- The number of collection updates
-
numberOfCollectionCreations
public int numberOfCollectionCreations()Description copied from interface:ActionQueueGet the number of collection creations.- Specified by:
numberOfCollectionCreationsin interfaceActionQueue- Returns:
- The number of collection creations
-
numberOfDeletions
public int numberOfDeletions()Description copied from interface:ActionQueueGet the number of deletions.- Specified by:
numberOfDeletionsin interfaceActionQueue- Returns:
- The number of deletions
-
numberOfUpdates
public int numberOfUpdates()Description copied from interface:ActionQueueGet the number of updates.- Specified by:
numberOfUpdatesin interfaceActionQueue- Returns:
- The number of updates
-
numberOfInsertions
public int numberOfInsertions()Description copied from interface:ActionQueueGet the number of insertions.- Specified by:
numberOfInsertionsin interfaceActionQueue- Returns:
- The number of insertions
-
getTransactionCompletionCallbacks
Description copied from interface:ActionQueueGet the transaction completion callbacks.- Specified by:
getTransactionCompletionCallbacksin interfaceActionQueue- 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:
setTransactionCompletionCallbacksin interfaceActionQueue- Parameters:
callbacks- Transaction completion callbacks.isTransactionCoordinatorShared- Flag indicating shared transaction context.
-
sortCollectionActions
public void sortCollectionActions()Description copied from interface:ActionQueueSort collection actions if ordering is enabled.- Specified by:
sortCollectionActionsin interfaceActionQueue
-
sortActions
public void sortActions()Description copied from interface:ActionQueueSort entity actions if ordering is enabled.- Specified by:
sortActionsin interfaceActionQueue
-
clearFromFlushNeededCheck
public void clearFromFlushNeededCheck(int previousCollectionRemovalSize) Description copied from interface:ActionQueueClear actions that were added during a flush needed check.- Specified by:
clearFromFlushNeededCheckin interfaceActionQueue- Parameters:
previousCollectionRemovalSize- The previous collection removal size
-
hasAfterTransactionActions
public boolean hasAfterTransactionActions()Description copied from interface:ActionQueueCheck if there are after-transaction actions.- Specified by:
hasAfterTransactionActionsin interfaceActionQueue- Returns:
- true if there are after-transaction actions
-
hasBeforeTransactionActions
public boolean hasBeforeTransactionActions()Description copied from interface:ActionQueueCheck if there are before-transaction actions.- Specified by:
hasBeforeTransactionActionsin interfaceActionQueue- Returns:
- true if there are before-transaction actions
-
hasAnyQueuedActions
public boolean hasAnyQueuedActions()Description copied from interface:ActionQueueCheck if there are any queued actions.- Specified by:
hasAnyQueuedActionsin interfaceActionQueue- Returns:
- true if there are any queued actions
-
unScheduleUnloadedDeletion
Description copied from interface:ActionQueueUn-schedule a deletion for an unloaded entity.- Specified by:
unScheduleUnloadedDeletionin interfaceActionQueue- Parameters:
newEntity- The entity being persisted
-
unScheduleDeletion
Description copied from interface:ActionQueueUn-schedule a deletion for an entity.- Specified by:
unScheduleDeletionin interfaceActionQueue- Parameters:
entry- The entity entryrescuedEntity- The entity being rescued from deletion
-
serialize
Used by the owning session to explicitly control serialization of the action queue- Specified by:
serializein interfaceActionQueue- 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 queuesession- The session to which the action queue belongs- Returns:
- The deserialized action queue
- Throws:
IOException- indicates a problem reading from the streamClassNotFoundException- Generally means we were unable to locate user classes.
-