public class ActionQueue extends Object
Responsible for maintaining the queue of actions related to events.
The ActionQueue 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.
Modifier and Type | Class and Description |
---|---|
static class |
ActionQueue.TransactionCompletionProcesses
Wrapper class allowing to bind the same transaction completion process queues in different sessions.
|
Constructor and Description |
---|
ActionQueue(SessionImplementor session)
Constructs an action queue bound to the given session.
|
Modifier and Type | Method and Description |
---|---|
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)
|
void |
addAction(org.hibernate.action.internal.CollectionRecreateAction action)
Adds a collection (re)create action
|
void |
addAction(org.hibernate.action.internal.CollectionRemoveAction action)
Adds a collection remove action
|
void |
addAction(org.hibernate.action.internal.CollectionUpdateAction action)
Adds a collection update action
|
void |
addAction(org.hibernate.action.internal.EntityDeleteAction action)
Adds an entity delete action
|
void |
addAction(org.hibernate.action.internal.EntityIdentityInsertAction action)
Adds an entity (IDENTITY) insert action
|
void |
addAction(org.hibernate.action.internal.EntityInsertAction action)
Adds an entity insert action
|
void |
addAction(org.hibernate.action.internal.EntityUpdateAction action)
Adds an entity update action
|
void |
addAction(org.hibernate.action.internal.OrphanRemovalAction action)
Adds an orphan removal action
|
void |
addAction(org.hibernate.action.internal.QueuedOperationCollectionAction action)
Adds an action relating to a collection queued operation (extra lazy).
|
void |
afterTransactionCompletion(boolean success)
Performs cleanup of any held cache softlocks.
|
boolean |
areInsertionsOrDeletionsQueued()
Check whether any insertion or deletion actions are currently queued.
|
boolean |
areTablesToBeUpdated(Set tables)
Check whether the given tables/query-spaces are to be executed against given the currently queued actions.
|
void |
beforeTransactionCompletion()
Execute any registered
BeforeTransactionCompletionProcess |
void |
checkNoUnresolvedActionsAfterOperation()
Throws
PropertyValueException if there are any unresolved entity insert actions that depend
on non-nullable associations with a transient entity. |
void |
clear() |
void |
clearFromFlushNeededCheck(int previousCollectionRemovalSize) |
static ActionQueue |
deserialize(ObjectInputStream ois,
SessionImplementor session)
Used by the owning session to explicitly control deserialization of the action queue.
|
<E extends Executable & Comparable<?>> |
execute(E executable) |
void |
executeActions()
Perform all currently queued actions.
|
void |
executeInserts()
Perform all currently queued entity-insertion actions.
|
ActionQueue.TransactionCompletionProcesses |
getTransactionCompletionProcesses() |
boolean |
hasAfterTransactionActions() |
boolean |
hasAnyQueuedActions() |
boolean |
hasBeforeTransactionActions() |
boolean |
hasUnresolvedEntityInsertActions()
Are there unresolved entity insert actions that depend on non-nullable associations with a transient entity?
|
int |
numberOfCollectionCreations() |
int |
numberOfCollectionRemovals() |
int |
numberOfCollectionUpdates() |
int |
numberOfDeletions() |
int |
numberOfInsertions() |
int |
numberOfUpdates() |
void |
prepareActions()
Prepares the internal action queues for execution.
|
void |
registerProcess(AfterTransactionCompletionProcess process) |
void |
registerProcess(BeforeTransactionCompletionProcess process) |
void |
serialize(ObjectOutputStream oos)
Used by the owning session to explicitly control serialization of the action queue
|
void |
setTransactionCompletionProcesses(ActionQueue.TransactionCompletionProcesses processes,
boolean isTransactionCoordinatorShared)
Bind transaction completion processes to make them shared between primary and secondary session.
|
void |
sortActions() |
void |
sortCollectionActions() |
String |
toString()
Returns a string representation of the object.
|
void |
unScheduleDeletion(EntityEntry entry,
Object rescuedEntity) |
public ActionQueue(SessionImplementor session)
Constructs an action queue bound to the given session.
session
- The session "owning" this queue.public void clear()
public void addAction(org.hibernate.action.internal.EntityInsertAction action)
Adds an entity insert action
action
- The action representing the entity insertionpublic void addAction(org.hibernate.action.internal.EntityIdentityInsertAction action)
Adds an entity (IDENTITY) insert action
action
- The action representing the entity insertionpublic void addAction(org.hibernate.action.internal.EntityDeleteAction action)
Adds an entity delete action
action
- The action representing the entity deletionpublic void addAction(org.hibernate.action.internal.OrphanRemovalAction action)
Adds an orphan removal action
action
- The action representing the orphan removalpublic void addAction(org.hibernate.action.internal.EntityUpdateAction action)
Adds an entity update action
action
- The action representing the entity updatepublic void addAction(org.hibernate.action.internal.CollectionRecreateAction action)
Adds a collection (re)create action
action
- The action representing the (re)creation of a collectionpublic void addAction(org.hibernate.action.internal.CollectionRemoveAction action)
Adds a collection remove action
action
- The action representing the removal of a collectionpublic void addAction(org.hibernate.action.internal.CollectionUpdateAction action)
Adds a collection update action
action
- The action representing the update of a collectionpublic void addAction(org.hibernate.action.internal.QueuedOperationCollectionAction action)
Adds an action relating to a collection queued operation (extra lazy).
action
- The action representing the queued operationpublic 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)
action
- The action representing the queued operationpublic boolean hasUnresolvedEntityInsertActions()
Are there unresolved entity insert actions that depend on non-nullable associations with a transient entity?
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.
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.public void registerProcess(AfterTransactionCompletionProcess process)
public void registerProcess(BeforeTransactionCompletionProcess process)
public void executeInserts() throws HibernateException
Perform all currently queued entity-insertion actions.
HibernateException
- error executing queued insertion actions.public void executeActions() throws HibernateException
Perform all currently queued actions.
HibernateException
- error executing queued actions.public void prepareActions() throws HibernateException
Prepares the internal action queues for execution.
HibernateException
- error preparing actions.public void afterTransactionCompletion(boolean success)
Performs cleanup of any held cache softlocks.
success
- Was the transaction successful.public void beforeTransactionCompletion()
Execute any registered BeforeTransactionCompletionProcess
public boolean areInsertionsOrDeletionsQueued()
Check whether any insertion or deletion actions are currently queued.
true
if insertions or deletions are currently queued; false
otherwise.public boolean areTablesToBeUpdated(Set tables)
Check whether the given tables/query-spaces are to be executed against given the currently queued actions.
tables
- The table/query-spaces to check.true
if we contain pending actions against any of the given tables; false
otherwise.public <E extends Executable & Comparable<?>> void execute(E executable)
executable
- The action to executepublic String toString()
Returns a string representation of the object.
public int numberOfCollectionRemovals()
public int numberOfCollectionUpdates()
public int numberOfCollectionCreations()
public int numberOfDeletions()
public int numberOfUpdates()
public int numberOfInsertions()
public ActionQueue.TransactionCompletionProcesses getTransactionCompletionProcesses()
public void setTransactionCompletionProcesses(ActionQueue.TransactionCompletionProcesses processes, 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.
processes
- Transaction completion processes.isTransactionCoordinatorShared
- Flag indicating shared transaction context.public void sortCollectionActions()
public void sortActions()
public void clearFromFlushNeededCheck(int previousCollectionRemovalSize)
public boolean hasAfterTransactionActions()
public boolean hasBeforeTransactionActions()
public boolean hasAnyQueuedActions()
public void unScheduleDeletion(EntityEntry entry, Object rescuedEntity)
public void serialize(ObjectOutputStream oos) throws IOException
Used by the owning session to explicitly control serialization of the action queue
oos
- The stream to which the action queue should get writtenIOException
- Indicates an error writing to the streampublic static ActionQueue deserialize(ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundException
Used by the owning session to explicitly control deserialization of the action queue.
ois
- The stream from which to read the action queuesession
- The session to which the action queue belongsIOException
- indicates a problem reading from the streamClassNotFoundException
- Generally means we were unable to locate user classes.Copyright © 2001-2018 Red Hat, Inc. All Rights Reserved.