Top Description Fields Constructors Methods
org.eclipse.persistence.internal.sessions

public Class CommitManager

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collection, .Collections, .IdentityHashMap, .Iterator, .LinkedHashMap, .List, .Map, .TreeMap, .Vector, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DatabaseException, .OptimisticLockException, org.eclipse.persistence.internal.databaseaccess.DatasourceCall, org.eclipse.persistence.internal.helper.DatabaseTable, .DescriptorCompare, .Helper, org.eclipse.persistence.internal.localization.ToStringLocalization, org.eclipse.persistence.internal.queries.DatabaseQueryMechanism, org.eclipse.persistence.mappings.DatabaseMapping, org.eclipse.persistence.queries.DeleteObjectQuery, .InsertObjectQuery, .UpdateObjectQuery, .WriteObjectQuery, org.eclipse.persistence.sessions.UnitOfWork.CommitOrderType

This class maintains a commit stack and resolves circular references.

Field Summary

Modifier and TypeField and Description
protected int
commitDepth

Counter used to keep track of commit depth for non-UOW writes.

protected List<Class<?>>
commitOrder

Order based on mapping foreign key constraints on how to insert objects by class.

protected Map<Object, Integer>
commitState

This tracks the commit state for the objects, PENDING, PRE, POST, COMPLETE.

protected static final Integer
COMPLETE

The commit is complete for the object.

protected Map<DatabaseMapping, List<Object[]>>
dataModifications

Map of modification events used to defer insertion into m-m, dc, join tables.

protected Map<DatabaseTable, List<Object[]>>
deferredCalls

Map of deferred calls groups by their table.

protected static final Integer
IGNORE

This object should be ignored.

protected boolean
isActive

The commit manager is active while writing a set of objects (UOW), it is not active when writing a single object (DB session).

protected List<E>
objectsToDelete

List of orphaned objects pending deletion.

protected static final Integer
POST

The commit is in progress, and the row has been written.

protected static final Integer
PRE

The commit is in progress, but the row has not been written.

protected AbstractSession
protected Map<K, V>
shallowCommits

Set of objects that had partial row written to resolve constraints.

Constructor Summary

AccessConstructor and Description
public
CommitManager(AbstractSession session)

Create the commit manager on the session.

Method Summary

Modifier and TypeMethod and Description
public void
addDataModificationEvent(DatabaseMapping mapping, Object[] event)

Add the data query to be performed at the end of the commit.

public void
addDeferredCall(DatabaseTable table, DatasourceCall call, DatabaseQueryMechanism mechanism)

Add the data query to be performed at the end of the commit.

public void
addObjectToDelete(Object objectToDelete)

Deletion are cached until the end.

protected void
commitAllObjectsForClassWithChangeSet(UnitOfWorkChangeSet uowChangeSet, Class<?> theClass)

Commit all of the objects of the class type in the change set.

public void
commitAllObjectsWithChangeSet(UnitOfWorkChangeSet uowChangeSet)

Commit all of the objects as a single transaction.

protected void
commitChangedObjectsForClassWithChangeSet(UnitOfWorkChangeSet uowChangeSet, Class<?> theClass)

Commit changed of the objects of the class type in the change set.

protected void
commitNewObjectsForClassWithChangeSet(UnitOfWorkChangeSet uowChangeSet, Class<?> theClass)

Commit all of the objects of the class type in the change set.

public void
deleteAllObjects(List<E> objects)

delete all of the objects as a single transaction.

public void
deleteAllObjects(Class<?> theClass, List<E> objects, AbstractSession session)

Delete all of the objects with the matching class.

public List<Class<?>>
getCommitOrder()

Return the order in which objects should be committed to the database.

protected Map<Object, Integer>
getCommitState()

Return the map of states of the objects being committed.

protected Map<DatabaseMapping, List<Object[]>>
getDataModifications()

Used to store data queries to be performed at the end of the commit.

protected Map<DatabaseTable, List<Object[]>>
getDeferredCalls()

Used to store calls to be performed at the end of the commit.

public List<E>
getObjectsToDelete()

Deletion are cached until the end.

protected AbstractSession
getSession()

Return the session that this is managing commits for.

protected Map<K, V>
getShallowCommits()

Return any objects that have been shallow committed during this commit process.

protected boolean
protected boolean
protected boolean
public void
initializeCommitOrder()

Reset the commit order from the session's descriptors.

public boolean
isActive()

Return if the commit manager is active.

public boolean
isCommitCompleted(Object object)

Return if the object has been committed.

public boolean
isCommitCompletedInPostOrIgnore(Object object)

Return if the object has been committed.

public boolean
isCommitInPostModify(Object object)

Return if the object is being in progress of being post modify commit.

public boolean
isCommitInPreModify(Object objectOrChangeSet)

Return if the object is being in progress of being pre modify commit.

public boolean
isProcessedCommit(Object object)

Return if the object has been processed.

public boolean
isShallowCommitted(Object object)

Return if the object is shallow committed.

public void
markCommitCompleted(Object object)

Mark the commit of the object as being fully completed.

public void
public void
markPostModifyCommitInProgress(Object object)

Add an object as being in progress of being committed.

public void
markPreModifyCommitInProgress(Object object)

Add an object as being in progress of being committed.

public void
markShallowCommit(Object object)

Mark the object as shallow committed.

public void
reinitialize()

Reset the commits.

public void
setCommitOrder(List<E> commitOrder)

Set the order in which objects should be committed to the database.

protected void
setDataModifications(Map<DatabaseMapping, List<Object[]>> dataModifications)

Used to store data queries to be performed at the end of the commit.

public void
setIsActive(boolean isActive)

Set if the commit manager is active.

protected void
setObjectsToDelete(List<E> objectsToDelete)

Deletion are cached until the end.

protected void
setSession(AbstractSession session)

Set the session that this is managing commits for.

protected void
setShallowCommits(Map<K, V> shallowCommits)

Set any objects that have been shallow committed during this commit process.

private List<E>
sort(Class<?> theClass, List<E> objects)

Sort the objects based on PK.

public String
toString()

Overrides java.lang.Object.toString.

Print the in progress depth.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

commitDepthback to summary
protected int commitDepth

Counter used to keep track of commit depth for non-UOW writes.

commitOrderback to summary
protected List<Class<?>> commitOrder

Order based on mapping foreign key constraints on how to insert objects by class.

commitStateback to summary
protected Map<Object, Integer> commitState

This tracks the commit state for the objects, PENDING, PRE, POST, COMPLETE. The key is the object and the value is the state.

COMPLETEback to summary
protected static final Integer COMPLETE

The commit is complete for the object.

dataModificationsback to summary
protected Map<DatabaseMapping, List<Object[]>> dataModifications

Map of modification events used to defer insertion into m-m, dc, join tables.

deferredCallsback to summary
protected Map<DatabaseTable, List<Object[]>> deferredCalls

Map of deferred calls groups by their table. This is used to defer multiple table writes for batching and deadlock avoidance.

IGNOREback to summary
protected static final Integer IGNORE

This object should be ignored.

isActiveback to summary
protected boolean isActive

The commit manager is active while writing a set of objects (UOW), it is not active when writing a single object (DB session).

objectsToDeleteback to summary
protected List<E> objectsToDelete

List of orphaned objects pending deletion.

POSTback to summary
protected static final Integer POST

The commit is in progress, and the row has been written.

PREback to summary
protected static final Integer PRE

The commit is in progress, but the row has not been written.

sessionback to summary
protected AbstractSession session
shallowCommitsback to summary
protected Map<K, V> shallowCommits

Set of objects that had partial row written to resolve constraints.

Constructor Detail

CommitManagerback to summary
public CommitManager(AbstractSession session)

Create the commit manager on the session. It must be initialized later on after the descriptors have been added.

Method Detail

addDataModificationEventback to summary
public void addDataModificationEvent(DatabaseMapping mapping, Object[] event)

Add the data query to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock.

addDeferredCallback to summary
public void addDeferredCall(DatabaseTable table, DatasourceCall call, DatabaseQueryMechanism mechanism)

Add the data query to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock.

addObjectToDeleteback to summary
public void addObjectToDelete(Object objectToDelete)

Deletion are cached until the end.

commitAllObjectsForClassWithChangeSetback to summary
protected void commitAllObjectsForClassWithChangeSet(UnitOfWorkChangeSet uowChangeSet, Class<?> theClass)

Commit all of the objects of the class type in the change set. This allows for the order of the classes to be processed optimally.

commitAllObjectsWithChangeSetback to summary
public void commitAllObjectsWithChangeSet(UnitOfWorkChangeSet uowChangeSet) throws RuntimeException, DatabaseException, OptimisticLockException

Commit all of the objects as a single transaction. This should commit the object in the correct order to maintain referential integrity.

commitChangedObjectsForClassWithChangeSetback to summary
protected void commitChangedObjectsForClassWithChangeSet(UnitOfWorkChangeSet uowChangeSet, Class<?> theClass)

Commit changed of the objects of the class type in the change set. This allows for the order of the classes to be processed optimally.

commitNewObjectsForClassWithChangeSetback to summary
protected void commitNewObjectsForClassWithChangeSet(UnitOfWorkChangeSet uowChangeSet, Class<?> theClass)

Commit all of the objects of the class type in the change set. This allows for the order of the classes to be processed optimally.

deleteAllObjectsback to summary
public void deleteAllObjects(List<E> objects) throws RuntimeException, DatabaseException, OptimisticLockException

delete all of the objects as a single transaction. This should delete the object in the correct order to maintain referential integrity.

deleteAllObjectsback to summary
public void deleteAllObjects(Class<?> theClass, List<E> objects, AbstractSession session)

Delete all of the objects with the matching class.

getCommitOrderback to summary
public List<Class<?>> getCommitOrder()

Return the order in which objects should be committed to the database. This order is based on ownership in the descriptors and is require for referential integrity. The commit order is a vector of vectors, where the first vector is all root level classes, the second is classes owned by roots and so on.

getCommitStateback to summary
protected Map<Object, Integer> getCommitState()

Return the map of states of the objects being committed. The states are defined as static Integers (PENDING, PRE, POST, COMPLETE).

getDataModificationsback to summary
protected Map<DatabaseMapping, List<Object[]>> getDataModifications()

Used to store data queries to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock.

getDeferredCallsback to summary
protected Map<DatabaseTable, List<Object[]>> getDeferredCalls()

Used to store calls to be performed at the end of the commit. This is done for multiple table descriptors to allow batching and avoid deadlock.

getObjectsToDeleteback to summary
public List<E> getObjectsToDelete()

Deletion are cached until the end.

getSessionback to summary
protected AbstractSession getSession()

Return the session that this is managing commits for.

getShallowCommitsback to summary
protected Map<K, V> getShallowCommits()

Return any objects that have been shallow committed during this commit process.

hasDataModificationsback to summary
protected boolean hasDataModifications()
hasDeferredCallsback to summary
protected boolean hasDeferredCalls()
hasObjectsToDeleteback to summary
protected boolean hasObjectsToDelete()
initializeCommitOrderback to summary
public void initializeCommitOrder()

Reset the commit order from the session's descriptors. This uses the constraint dependencies in the descriptor's mappings, to decide which descriptors are dependent on which other descriptors. Multiple computations of the commit order should produce the same ordering. This is done to improve performance on unit of work writes through decreasing the stack size, and acts as a deadlock avoidance mechanism.

isActiveback to summary
public boolean isActive()

Return if the commit manager is active.

isCommitCompletedback to summary
public boolean isCommitCompleted(Object object)

Return if the object has been committed. This should be called by any query that is writing an object, if true the query should not write the object.

isCommitCompletedInPostOrIgnoreback to summary
public boolean isCommitCompletedInPostOrIgnore(Object object)

Return if the object has been committed. This should be called by any query that is writing an object, if true the query should not write the object.

isCommitInPostModifyback to summary
public boolean isCommitInPostModify(Object object)

Return if the object is being in progress of being post modify commit. This should be called by any query that is writing an object.

isCommitInPreModifyback to summary
public boolean isCommitInPreModify(Object objectOrChangeSet)

Return if the object is being in progress of being pre modify commit. This should be called by any query that is writing an object, if true the query must force a shallow insert of the object if it is new.

isProcessedCommitback to summary
public boolean isProcessedCommit(Object object)

Return if the object has been processed. This should be called by any query that is writing an object, if true the query should not write the object.

isShallowCommittedback to summary
public boolean isShallowCommitted(Object object)

Return if the object is shallow committed. This is required to resolve bidirectional references.

markCommitCompletedback to summary
public void markCommitCompleted(Object object)

Mark the commit of the object as being fully completed. This should be called by any query that has finished writing an object.

markIgnoreCommitback to summary
public void markIgnoreCommit(Object object)
markPostModifyCommitInProgressback to summary
public void markPostModifyCommitInProgress(Object object)

Add an object as being in progress of being committed. This should be called by any query that is writing an object.

markPreModifyCommitInProgressback to summary
public void markPreModifyCommitInProgress(Object object)

Add an object as being in progress of being committed. This should be called by any query that is writing an object.

markShallowCommitback to summary
public void markShallowCommit(Object object)

Mark the object as shallow committed. This is required to resolve bidirectional references.

reinitializeback to summary
public void reinitialize()

Reset the commits. This must be done before a new commit process is begun.

setCommitOrderback to summary
public void setCommitOrder(List<E> commitOrder)

Set the order in which objects should be committed to the database. This order is based on ownership in the descriptors and is require for referential integrity. The commit order is a vector of vectors, where the first vector is all root level classes, the second is classes owned by roots and so on.

setDataModificationsback to summary
protected void setDataModifications(Map<DatabaseMapping, List<Object[]>> dataModifications)

Used to store data queries to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock.

setIsActiveback to summary
public void setIsActive(boolean isActive)

Set if the commit manager is active.

setObjectsToDeleteback to summary
protected void setObjectsToDelete(List<E> objectsToDelete)

Deletion are cached until the end.

setSessionback to summary
protected void setSession(AbstractSession session)

Set the session that this is managing commits for.

setShallowCommitsback to summary
protected void setShallowCommits(Map<K, V> shallowCommits)

Set any objects that have been shallow committed during this commit process.

sortback to summary
private List<E> sort(Class<?> theClass, List<E> objects)

Sort the objects based on PK.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Print the in progress depth.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override