Interface ActionQueue
- All Superinterfaces:
TransactionCompletionCallbacks
- All Known Implementing Classes:
ActionQueueLegacy
@Incubating(since="8.0",
group="action-queue")
public interface ActionQueue
extends TransactionCompletionCallbacks
Common interface for ActionQueue implementations.
The ActionQueue is responsible for managing and executing all pending persistence actions (inserts, updates, deletes, etc.) in a Hibernate session. Different implementations may use different execution strategies.
- Since:
- 8.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface TransactionCompletionCallbacks
TransactionCompletionCallbacks.AfterCompletionCallback, TransactionCompletionCallbacks.BeforeCompletionCallback, TransactionCompletionCallbacks.CompletionCallback -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAction(org.hibernate.action.internal.BulkOperationCleanupAction action) Adds a bulk operation cleanup action.voidaddAction(org.hibernate.action.internal.EntityDeleteAction action) Adds an entity delete action.voidaddAction(org.hibernate.action.internal.EntityIdentityInsertAction action) Adds an identity-based entity insert action.voidaddAction(org.hibernate.action.internal.EntityInsertAction action) Adds an entity insert action.voidaddAction(org.hibernate.action.internal.EntityUpdateAction action) Adds an entity update action.voidaddAction(org.hibernate.action.internal.OrphanRemovalAction action) Adds an orphan removal action.voidAdds queue-neutral collection mutation input produced by flush visitation.voidafterTransactionCompletion(boolean success) Execute actions after transaction completion.booleanCheck if there are insertions or deletions queued.booleanareTablesToBeUpdated(Set<? extends Serializable> tables) Check if any of the specified tables are scheduled for update.voidExecute actions before transaction completion.voidCheck that there are no unresolved actions after an operation.Capture this queue's state before speculative flush preparation.voidclear()Clear all pending actions.voidExecute all pending actions.voidExecute identity insert 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.booleanCheck if there are unresolved entity insert actions.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.voidPrepare actions for execution (validation, sorting, etc.).voidrestore(ActionQueueCheckpoint checkpoint) Restore this queue after a speculative flush-needed check determines that execution is unnecessary.voidSerialize the action queue.voidsetAuditChangesetContext(Object changelog, Session changesetSession) Record the changelog context generated while binding legacy audit mutations.voidsetTransactionCompletionCallbacks(TransactionCompletionCallbacksImplementor callbacks, boolean isTransactionCoordinatorShared) Deprecated, for removal: This API element is subject to removal in a future version.default voidDeprecated, for removal: This API element is subject to removal in a future version.This method is not used byGraphBasedActionQueueand is only needed forActionQueueLegacy.default voidDeprecated, for removal: This API element is subject to removal in a future version.This method is not used byGraphBasedActionQueueand is only needed forActionQueueLegacy.voidunScheduleDeletion(EntityEntry entry, Object rescuedEntity) Un-schedule a deletion for an entity.voidunScheduleUnloadedDeletion(Object newEntity) Un-schedule a deletion for an unloaded entity.Methods inherited from interface TransactionCompletionCallbacks
registerCallback, registerCallback
-
Method Details
-
clear
void clear()Clear all pending actions. -
addAction
void addAction(org.hibernate.action.internal.EntityInsertAction action) Adds an entity insert action.- Parameters:
action- The action representing the entity insertion
-
addAction
void addAction(org.hibernate.action.internal.EntityIdentityInsertAction action) Adds an identity-based entity insert action.- Parameters:
action- The action representing the entity insertion with identity generation
-
addAction
void addAction(org.hibernate.action.internal.EntityUpdateAction action) Adds an entity update action.- Parameters:
action- The action representing the entity update
-
addAction
void addAction(org.hibernate.action.internal.EntityDeleteAction action) Adds an entity delete action.- Parameters:
action- The action representing the entity deletion
-
addAction
void addAction(org.hibernate.action.internal.OrphanRemovalAction action) Adds an orphan removal action.- Parameters:
action- The action representing orphan removal
-
addCollectionMutation
Adds queue-neutral collection mutation input produced by flush visitation.
The queue must retain this input without lifecycle side effects until a positive speculative-flush decision has been made.
- Parameters:
input- The queue-neutral semantic collection mutation- Since:
- 8.0
-
addAction
void addAction(org.hibernate.action.internal.BulkOperationCleanupAction action) Adds a bulk operation cleanup action.- Parameters:
action- The action representing bulk operation cleanup
-
executeInserts
Execute identity insert actions.- Throws:
HibernateException- If an error occurs during execution
-
executeActions
Execute all pending actions.- Throws:
HibernateException- If an error occurs during execution
-
prepareActions
Prepare actions for execution (validation, sorting, etc.).- Throws:
HibernateException- If an error occurs during preparation
-
executePendingBulkOperationCleanUpActions
void executePendingBulkOperationCleanUpActions()Execute pending bulk operation cleanup actions. -
hasUnresolvedEntityInsertActions
boolean hasUnresolvedEntityInsertActions()Check if there are unresolved entity insert actions.- Returns:
- true if there are unresolved entity insert actions
-
hasAnyQueuedActions
boolean hasAnyQueuedActions()Check if there are any queued actions.- Returns:
- true if there are any queued actions
-
hasBeforeTransactionActions
boolean hasBeforeTransactionActions()Check if there are before-transaction actions.- Returns:
- true if there are before-transaction actions
-
hasAfterTransactionActions
boolean hasAfterTransactionActions()Check if there are after-transaction actions.- Returns:
- true if there are after-transaction actions
-
areInsertionsOrDeletionsQueued
boolean areInsertionsOrDeletionsQueued()Check if there are insertions or deletions queued.- Returns:
- true if there are insertions or deletions queued
-
areTablesToBeUpdated
Check if any of the specified tables are scheduled for update.- Parameters:
tables- The set of table names to check- Returns:
- true if any of the tables are scheduled for update
-
checkNoUnresolvedActionsAfterOperation
Check that there are no unresolved actions after an operation.- Throws:
PropertyValueException- If there are unresolved actions
-
numberOfInsertions
int numberOfInsertions()Get the number of insertions.- Returns:
- The number of insertions
-
numberOfUpdates
int numberOfUpdates()Get the number of updates.- Returns:
- The number of updates
-
numberOfDeletions
int numberOfDeletions()Get the number of deletions.- Returns:
- The number of deletions
-
numberOfCollectionCreations
int numberOfCollectionCreations()Get the number of collection creations.- Returns:
- The number of collection creations
-
numberOfCollectionUpdates
int numberOfCollectionUpdates()Get the number of collection updates.- Returns:
- The number of collection updates
-
numberOfCollectionRemovals
int numberOfCollectionRemovals()Get the number of collection removals.- Returns:
- The number of collection removals
-
getTransactionCompletionCallbacks
TransactionCompletionCallbacksImplementor getTransactionCompletionCallbacks()Get the transaction completion callbacks.- Returns:
- The transaction completion callbacks implementor
-
setTransactionCompletionCallbacks
@Deprecated(since="7.0", forRemoval=true) void setTransactionCompletionCallbacks(TransactionCompletionCallbacksImplementor callbacks, boolean isTransactionCoordinatorShared) Deprecated, for removal: This API element is subject to removal in a future version.This method is not used byGraphBasedActionQueueand is only needed forActionQueueLegacy. It will be removed when the legacy implementation is removed.Set the transaction completion callbacks.- Parameters:
callbacks- The transaction completion callbacksisTransactionCoordinatorShared- Whether the transaction coordinator is shared
-
beforeTransactionCompletion
void beforeTransactionCompletion()Execute actions before transaction completion. -
setAuditChangesetContext
Record the changelog context generated while binding legacy audit mutations.- Parameters:
changelog- The changelog entity instancechangesetSession- The child session used to persist the changelog entity- API Note:
- This hook exists for
ActionQueueLegacy, whose audit work queue receives changelog context as a side effect of resolving the current changeset id. The graph queue resolves changelog context directly from the session and ignores this callback.
-
afterTransactionCompletion
void afterTransactionCompletion(boolean success) Execute actions after transaction completion.- Parameters:
success- Whether the transaction completed successfully
-
sortActions
Deprecated, for removal: This API element is subject to removal in a future version.This method is not used byGraphBasedActionQueueand is only needed forActionQueueLegacy. It will be removed when the legacy implementation is removed.Sort entity actions if ordering is enabled. -
sortCollectionActions
Deprecated, for removal: This API element is subject to removal in a future version.This method is not used byGraphBasedActionQueueand is only needed forActionQueueLegacy. It will be removed when the legacy implementation is removed.Sort collection actions if ordering is enabled. -
unScheduleUnloadedDeletion
Un-schedule a deletion for an unloaded entity.- Parameters:
newEntity- The entity being persisted
-
unScheduleDeletion
Un-schedule a deletion for an entity.- Parameters:
entry- The entity entryrescuedEntity- The entity being rescued from deletion
-
checkpoint
ActionQueueCheckpoint checkpoint()Capture this queue's state before speculative flush preparation.
Work registered before the checkpoint survives
restore(ActionQueueCheckpoint). Work registered afterward is retained or discarded according to the semantic contract of its registration category. -
restore
Restore this queue after a speculative flush-needed check determines that execution is unnecessary.- Parameters:
checkpoint- A checkpoint previously created by this queue
-
serialize
Serialize the action queue.- Parameters:
oos- The object output stream- Throws:
IOException- If an I/O error occurs- See Also:
-
GraphBasedActionQueueand is only needed forActionQueueLegacy.