Top Description Inners Fields Constructors Methods
org.hibernate.engine

public Class ActionQueue

extends Object
Class Inheritance
Imports
java.io.IOException, .ObjectInputStream, .ObjectOutputStream, .Serializable, java.util.ArrayList, .HashMap, .HashSet, .LinkedList, .List, .Set, org.slf4j.Logger, .LoggerFactory, org.hibernate.AssertionFailure, .HibernateException, org.hibernate.action.AfterTransactionCompletionProcess, .BeforeTransactionCompletionProcess, .BulkOperationCleanupAction, .CollectionRecreateAction, .CollectionRemoveAction, .CollectionUpdateAction, .EntityDeleteAction, .EntityIdentityInsertAction, .EntityInsertAction, .EntityUpdateAction, .Executable, org.hibernate.cache.CacheException, org.hibernate.type.Type

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. DML operations are queued here until a flush forces them to be executed against the database.
Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private class
ActionQueue.InsertActionSorter

Sorts the insert actions using more hashes.

Field Summary

Modifier and TypeField and Description
private ActionQueue.AfterTransactionCompletionProcessQueue
private ActionQueue.BeforeTransactionCompletionProcessQueue
private ArrayList<E>
private ArrayList<E>
private ArrayList<E>
private ArrayList<E>
private static final int
private ArrayList<E>
private static final Logger
private SessionImplementor
private ArrayList<E>

Constructor Summary

AccessConstructor and Description
public
ActionQueue(SessionImplementor
The session "owning" this queue.
session
)

Constructs an action queue bound to the given session.

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
public void
public void
public void
public void
public void
public void
afterTransactionCompletion(boolean
Was the transaction successful.
success
)

Performs cleanup of any held cache softlocks.

public boolean

Returns:

True if insertions or deletions are currently queued; false otherwise.
areInsertionsOrDeletionsQueued
()

Check whether any insertion or deletion actions are currently queued.

public boolean

Returns:

True if we contain pending actions against any of the given tables; false otherwise.
areTablesToBeUpdated
(Set<E>
The table/query-spaces to check.
tables
)

Check whether the given tables/query-spaces are to be executed against given the currently queued actions.

private static boolean
areTablesToUpdated(List<E> actions, Set<E> tableSpaces)

public void
public void
public void
clearFromFlushNeededCheck(int previousCollectionRemovalSize)

public ArrayList<E>
public static ActionQueue

Returns:

The deserialized action queue
deserialize
(ObjectInputStream
The stream from which to read the action queue
ois
,
SessionImplementor
The session to which the action queue belongs
session
)

Used by the owning session to explicitly control deserialization of the action queue

public void
execute(Executable executable)

public void
executeActions()

Perform all currently queued actions.

private void
public void
executeInserts()

Perform all currently queued entity-insertion actions.

public boolean
public boolean
public boolean
private void
init()

public int
public int
public int
public int
public int
public int
public void
prepareActions()

Prepares the internal action queues for execution.

private void
prepareActions(List<E> queue)

private void
public void
public void
public void
serialize(ObjectOutputStream
The stream to which the action queue should get written
oos
)

Used by the owning session to explicitly control serialization of the action queue

public void
public void
private void
sortInsertActions()

Order the insertions queue such that we group inserts against the same entity together (without violating constraints).

public String

Returns:

a string representation of the object.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
unScheduleDeletion(EntityEntry entry, Object rescuedEntity)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

afterTransactionProcessesback to summary
private ActionQueue.AfterTransactionCompletionProcessQueue afterTransactionProcesses
beforeTransactionProcessesback to summary
private ActionQueue.BeforeTransactionCompletionProcessQueue beforeTransactionProcesses
collectionCreationsback to summary
private ArrayList<E> collectionCreations
collectionRemovalsback to summary
private ArrayList<E> collectionRemovals
collectionUpdatesback to summary
private ArrayList<E> collectionUpdates
deletionsback to summary
private ArrayList<E> deletions
INIT_QUEUE_LIST_SIZEback to summary
private static final int INIT_QUEUE_LIST_SIZE
insertionsback to summary
private ArrayList<E> insertions
logback to summary
private static final Logger log
sessionback to summary
private SessionImplementor session
updatesback to summary
private ArrayList<E> updates

Constructor Detail

ActionQueueback to summary
public ActionQueue(SessionImplementor session)

Constructs an action queue bound to the given session.

Parameters
session:SessionImplementor

The session "owning" this queue.

Method Detail

addActionback to summary
public void addAction(EntityInsertAction action)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(EntityDeleteAction action)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(EntityUpdateAction action)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(CollectionRecreateAction action)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(CollectionRemoveAction action)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(CollectionUpdateAction action)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(EntityIdentityInsertAction insert)
Annotations
@SuppressWarnings:unchecked
addActionback to summary
public void addAction(BulkOperationCleanupAction cleanupAction)
afterTransactionCompletionback to summary
public void afterTransactionCompletion(boolean success)

Performs cleanup of any held cache softlocks.

Parameters
success:boolean

Was the transaction successful.

areInsertionsOrDeletionsQueuedback to summary
public boolean areInsertionsOrDeletionsQueued()

Check whether any insertion or deletion actions are currently queued.

Returns:boolean

True if insertions or deletions are currently queued; false otherwise.

areTablesToBeUpdatedback to summary
public boolean areTablesToBeUpdated(Set<E> tables)

Check whether the given tables/query-spaces are to be executed against given the currently queued actions.

Parameters
tables:Set<E>

The table/query-spaces to check.

Returns:boolean

True if we contain pending actions against any of the given tables; false otherwise.

areTablesToUpdatedback to summary
private static boolean areTablesToUpdated(List<E> actions, Set<E> tableSpaces)
Annotations
@SuppressWarnings:unchecked
beforeTransactionCompletionback to summary
public void beforeTransactionCompletion()

Execute any registered BeforeTransactionCompletionProcess

clearback to summary
public void clear()
clearFromFlushNeededCheckback to summary
public void clearFromFlushNeededCheck(int previousCollectionRemovalSize)
cloneDeletionsback to summary
public ArrayList<E> cloneDeletions()
Annotations
@SuppressWarnings:UnusedDeclaration
deserializeback to summary
public static ActionQueue deserialize(ObjectInputStream ois, SessionImplementor session) throws IOException, ClassNotFoundException

Used by the owning session to explicitly control deserialization of the action queue

Parameters
ois:ObjectInputStream

The stream from which to read the action queue

session:SessionImplementor

The session to which the action queue belongs

Returns:ActionQueue

The deserialized action queue

Annotations
@SuppressWarnings:unchecked
Exceptions
IOException:
indicates a problem reading from the stream
ClassNotFoundException:
Generally means we were unable to locate user classes.
executeback to summary
public void execute(Executable executable)
executeActionsback to summary
public void executeActions() throws HibernateException

Perform all currently queued actions.

Exceptions
HibernateException:
error executing queued actions.
executeActionsback to summary
private void executeActions(List<E> list) throws HibernateException
executeInsertsback to summary
public void executeInserts() throws HibernateException

Perform all currently queued entity-insertion actions.

Exceptions
HibernateException:
error executing queued insertion actions.
hasAfterTransactionActionsback to summary
public boolean hasAfterTransactionActions()
Annotations
@SuppressWarnings:UnusedDeclaration
hasAnyQueuedActionsback to summary
public boolean hasAnyQueuedActions()
hasBeforeTransactionActionsback to summary
public boolean hasBeforeTransactionActions()
initback to summary
private void init()
numberOfCollectionCreationsback to summary
public int numberOfCollectionCreations()
numberOfCollectionRemovalsback to summary
public int numberOfCollectionRemovals()
numberOfCollectionUpdatesback to summary
public int numberOfCollectionUpdates()
numberOfDeletionsback to summary
public int numberOfDeletions()
numberOfInsertionsback to summary
public int numberOfInsertions()
numberOfUpdatesback to summary
public int numberOfUpdates()
prepareActionsback to summary
public void prepareActions() throws HibernateException

Prepares the internal action queues for execution.

Exceptions
HibernateException:
error preparing actions.
prepareActionsback to summary
private void prepareActions(List<E> queue) throws HibernateException
Annotations
@SuppressWarnings:unchecked
registerCleanupActionsback to summary
private void registerCleanupActions(Executable executable)
registerProcessback to summary
public void registerProcess(AfterTransactionCompletionProcess process)
registerProcessback to summary
public void registerProcess(BeforeTransactionCompletionProcess process)
serializeback to summary
public void serialize(ObjectOutputStream oos) throws IOException

Used by the owning session to explicitly control serialization of the action queue

Parameters
oos:ObjectOutputStream

The stream to which the action queue should get written

Exceptions
IOException:
Indicates an error writing to the stream
sortActionsback to summary
public void sortActions()
Annotations
@SuppressWarnings:unchecked
sortCollectionActionsback to summary
public void sortCollectionActions()
Annotations
@SuppressWarnings:unchecked
sortInsertActionsback to summary
private void sortInsertActions()

Order the insertions queue such that we group inserts against the same entity together (without violating constraints). The original order is generated by cascade order, which in turn is based on the directionality of foreign-keys. So even though we will be changing the ordering here, we need to make absolutely certain that we do not circumvent this FK ordering to the extent of causing constraint violations

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

unScheduleDeletionback to summary
public void unScheduleDeletion(EntityEntry entry, Object rescuedEntity)
org.hibernate.engine back to summary

private Class ActionQueue.AfterTransactionCompletionProcessQueue

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.engine.ActionQueue.AfterTransactionCompletionProcessQueue

Field Summary

Modifier and TypeField and Description
private List<AfterTransactionCompletionProcess>
private Set<String>
private SessionImplementor

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
afterTransactionCompletion(boolean success)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

processesback to summary
private List<AfterTransactionCompletionProcess> processes
querySpacesToInvalidateback to summary
private Set<String> querySpacesToInvalidate
sessionback to summary
private SessionImplementor session

Constructor Detail

AfterTransactionCompletionProcessQueueback to summary
private AfterTransactionCompletionProcessQueue(SessionImplementor session)

Method Detail

addSpacesToInvalidateback to summary
public void addSpacesToInvalidate(String[] spaces)
addSpaceToInvalidateback to summary
public void addSpaceToInvalidate(String space)
afterTransactionCompletionback to summary
public void afterTransactionCompletion(boolean success)
registerback to summary
public void register(AfterTransactionCompletionProcess process)
org.hibernate.engine back to summary

private Class ActionQueue.BeforeTransactionCompletionProcessQueue

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.engine.ActionQueue.BeforeTransactionCompletionProcessQueue

Field Summary

Modifier and TypeField and Description
private List<BeforeTransactionCompletionProcess>
private SessionImplementor

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

processesback to summary
private List<BeforeTransactionCompletionProcess> processes
sessionback to summary
private SessionImplementor session

Constructor Detail

BeforeTransactionCompletionProcessQueueback to summary
private BeforeTransactionCompletionProcessQueue(SessionImplementor session)

Method Detail

beforeTransactionCompletionback to summary
public void beforeTransactionCompletion()
registerback to summary
public void register(BeforeTransactionCompletionProcess process)
org.hibernate.engine back to summary

private Class ActionQueue.InsertActionSorter

extends Object
Class Inheritance

Sorts the insert actions using more hashes.
Author
Jay Erb

Field Summary

Modifier and TypeField and Description
private HashMap<K, V>
private HashMap<K, V>
private HashMap<K, V>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
addToBatch(Integer batchNumber, EntityInsertAction action)

private Integer

Returns:

An appropriate batch number; todo document this process better
findBatchNumber
(EntityInsertAction
The action being sorted
action
,
String
The name of the entity affected by the action
entityName
)

Finds an acceptable batch for this entity to be a member as part of the InsertActionSorter

public void
sort()

Sort the insert actions.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

actionBatchesback to summary
private HashMap<K, V> actionBatches
entityBatchNumberback to summary
private HashMap<K, V> entityBatchNumber
latestBatchesback to summary
private HashMap<K, V> latestBatches

Constructor Detail

InsertActionSorterback to summary
public InsertActionSorter()

Method Detail

addToBatchback to summary
private void addToBatch(Integer batchNumber, EntityInsertAction action)
Annotations
@SuppressWarnings:unchecked
findBatchNumberback to summary
private Integer findBatchNumber(EntityInsertAction action, String entityName)

Finds an acceptable batch for this entity to be a member as part of the InsertActionSorter

Parameters
action:EntityInsertAction

The action being sorted

entityName:String

The name of the entity affected by the action

Returns:Integer

An appropriate batch number; todo document this process better

Annotations
@SuppressWarnings:UnnecessaryBoxing, unchecked
sortback to summary
public void sort()

Sort the insert actions.

Annotations
@SuppressWarnings:unchecked, UnnecessaryBoxing