Package org.hibernate.reactive.engine
Class ReactiveActionQueue
- java.lang.Object
-
- org.hibernate.reactive.engine.ReactiveActionQueue
-
public class ReactiveActionQueue extends java.lang.ObjectA reactive counterpart toActionQueue, where DML operations are queued before execution during a flush.
-
-
Constructor Summary
Constructors Constructor Description ReactiveActionQueue(ReactiveSession session)Constructs an action queue bound to the given session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAction(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(QueuedOperationCollectionAction action)Adds an action relating to a collection queued operation (extra lazy).voidaddAction(ReactiveCollectionRecreateAction action)Adds a collection (re)create actionvoidaddAction(ReactiveCollectionRemoveAction action)Adds a collection remove actionvoidaddAction(ReactiveCollectionUpdateAction action)Adds a collection update actionvoidaddAction(ReactiveEntityDeleteAction action)Adds an entity delete actionjava.util.concurrent.CompletionStage<java.lang.Void>addAction(ReactiveEntityInsertAction action)Adds an entity (REGULAR) insert actionvoidaddAction(ReactiveEntityUpdateAction action)Adds an entity update actionvoidaddAction(ReactiveOrphanRemovalAction action)Adds an orphan removal actionjava.util.concurrent.CompletionStage<java.lang.Void>afterTransactionCompletion(boolean success)Performs cleanup of any held cache softlocks.booleanareInsertionsOrDeletionsQueued()Check whether any insertion or deletion actions are currently queued.booleanareTablesToBeUpdated(java.util.Set tables)Check whether the given tables/query-spaces are to be executed against given the currently queued actions.java.util.concurrent.CompletionStage<java.lang.Void>beforeTransactionCompletion()Execute any registeredBeforeTransactionCompletionProcessvoidcheckNoUnresolvedActionsAfterOperation()ThrowsPropertyValueExceptionif there are any unresolved entity insert actions that depend on non-nullable associations with a transient entity.voidclear()voidclearFromFlushNeededCheck(int previousCollectionRemovalSize)<E extends ReactiveExecutable>
java.util.concurrent.CompletionStage<java.lang.Void>execute(E executable)java.util.concurrent.CompletionStage<java.lang.Void>executeActions()Perform all currently queued actions.java.util.concurrent.CompletionStage<java.lang.Void>executeInserts()Perform all currently queued entity-insertion actions.booleanhasAfterTransactionActions()booleanhasAnyQueuedActions()booleanhasBeforeTransactionActions()booleanhasUnresolvedEntityInsertActions()Are there unresolved entity insert actions that depend on non-nullable associations with a transient entity?intnumberOfCollectionCreations()intnumberOfCollectionRemovals()intnumberOfCollectionUpdates()intnumberOfDeletions()intnumberOfInsertions()intnumberOfUpdates()voidprepareActions()Prepares the internal action queues for execution.voidregisterProcess(org.hibernate.action.spi.AfterTransactionCompletionProcess process)voidregisterProcess(org.hibernate.action.spi.BeforeTransactionCompletionProcess process)voidregisterProcess(ReactiveAfterTransactionCompletionProcess process)voidregisterProcess(ReactiveBeforeTransactionCompletionProcess process)voidsortActions()voidsortCollectionActions()java.lang.StringtoString()Returns a string representation of the object.voidunScheduleDeletion(org.hibernate.engine.spi.EntityEntry entry, java.lang.Object rescuedEntity)
-
-
-
Constructor Detail
-
ReactiveActionQueue
public ReactiveActionQueue(ReactiveSession session)
Constructs an action queue bound to the given session.- Parameters:
session- The session "owning" this queue.
-
-
Method Detail
-
clear
public void clear()
-
addAction
public java.util.concurrent.CompletionStage<java.lang.Void> addAction(ReactiveEntityInsertAction action)
Adds an entity (REGULAR) insert action- Parameters:
action- The action representing the entity insertion
-
addAction
public void addAction(ReactiveEntityDeleteAction action)
Adds an entity delete action- Parameters:
action- The action representing the entity deletion
-
addAction
public void addAction(ReactiveOrphanRemovalAction action)
Adds an orphan removal action- Parameters:
action- The action representing the orphan removal
-
addAction
public void addAction(ReactiveEntityUpdateAction action)
Adds an entity update action- Parameters:
action- The action representing the entity update
-
addAction
public void addAction(ReactiveCollectionRecreateAction action)
Adds a collection (re)create action- Parameters:
action- The action representing the (re)creation of a collection
-
addAction
public void addAction(ReactiveCollectionRemoveAction action)
Adds a collection remove action- Parameters:
action- The action representing the removal of a collection
-
addAction
public void addAction(ReactiveCollectionUpdateAction action)
Adds a collection update action- Parameters:
action- The action representing the update of a collection
-
addAction
public void addAction(QueuedOperationCollectionAction action)
Adds an action relating to a collection queued operation (extra lazy).- 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)- 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?- 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 org.hibernate.PropertyValueExceptionThrowsPropertyValueExceptionif 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.- Throws:
org.hibernate.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.
-
registerProcess
public void registerProcess(org.hibernate.action.spi.AfterTransactionCompletionProcess process)
-
registerProcess
public void registerProcess(org.hibernate.action.spi.BeforeTransactionCompletionProcess process)
-
registerProcess
public void registerProcess(ReactiveAfterTransactionCompletionProcess process)
-
registerProcess
public void registerProcess(ReactiveBeforeTransactionCompletionProcess process)
-
executeInserts
public java.util.concurrent.CompletionStage<java.lang.Void> executeInserts()
Perform all currently queued entity-insertion actions.- Throws:
org.hibernate.HibernateException- error executing queued insertion actions.
-
executeActions
public java.util.concurrent.CompletionStage<java.lang.Void> executeActions()
Perform all currently queued actions.- Throws:
org.hibernate.HibernateException- error executing queued actions.
-
prepareActions
public void prepareActions() throws org.hibernate.HibernateExceptionPrepares the internal action queues for execution.- Throws:
org.hibernate.HibernateException- error preparing actions.
-
afterTransactionCompletion
public java.util.concurrent.CompletionStage<java.lang.Void> afterTransactionCompletion(boolean success)
Performs cleanup of any held cache softlocks.- Parameters:
success- Was the transaction successful.
-
beforeTransactionCompletion
public java.util.concurrent.CompletionStage<java.lang.Void> beforeTransactionCompletion()
Execute any registeredBeforeTransactionCompletionProcess
-
areInsertionsOrDeletionsQueued
public boolean areInsertionsOrDeletionsQueued()
Check whether any insertion or deletion actions are currently queued.- Returns:
trueif insertions or deletions are currently queued;falseotherwise.
-
areTablesToBeUpdated
public boolean areTablesToBeUpdated(java.util.Set tables)
Check whether the given tables/query-spaces are to be executed against given the currently queued actions.- Parameters:
tables- The table/query-spaces to check.- Returns:
trueif we contain pending actions against any of the given tables;falseotherwise.
-
execute
public <E extends ReactiveExecutable> java.util.concurrent.CompletionStage<java.lang.Void> execute(E executable)
- Parameters:
executable- The action to execute
-
toString
public java.lang.String toString()
Returns a string representation of the object.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of the object.
-
numberOfCollectionRemovals
public int numberOfCollectionRemovals()
-
numberOfCollectionUpdates
public int numberOfCollectionUpdates()
-
numberOfCollectionCreations
public int numberOfCollectionCreations()
-
numberOfDeletions
public int numberOfDeletions()
-
numberOfUpdates
public int numberOfUpdates()
-
numberOfInsertions
public int numberOfInsertions()
-
sortCollectionActions
public void sortCollectionActions()
-
sortActions
public void sortActions()
-
clearFromFlushNeededCheck
public void clearFromFlushNeededCheck(int previousCollectionRemovalSize)
-
hasAfterTransactionActions
public boolean hasAfterTransactionActions()
-
hasBeforeTransactionActions
public boolean hasBeforeTransactionActions()
-
hasAnyQueuedActions
public boolean hasAnyQueuedActions()
-
unScheduleDeletion
public void unScheduleDeletion(org.hibernate.engine.spi.EntityEntry entry, java.lang.Object rescuedEntity)
-
-