Module org.eclipse.persistence.core
Class CommitManager
java.lang.Object
org.eclipse.persistence.internal.sessions.CommitManager
This class maintains a commit stack and resolves circular references.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
Counter used to keep track of commit depth for non-UOW writes.Order based on mapping foreign key constraints on how to insert objects by class.This tracks the commit state for the objects, PENDING, PRE, POST, COMPLETE.protected static final Integer
The commit is complete for the object.protected Map
<DatabaseMapping, List<Object[]>> Map of modification events used to defer insertion into m-m, dc, join tables.protected Map
<DatabaseTable, List<Object[]>> Map of deferred calls groups by their table.protected static final Integer
This object should be ignored.protected boolean
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
List of orphaned objects pending deletion.protected static final Integer
The commit is in progress, and the row has been written.protected static final Integer
The commit is in progress, but the row has not been written.protected AbstractSession
protected Map
Set of objects that had partial row written to resolve constraints. -
Constructor Summary
ConstructorsConstructorDescriptionCommitManager
(AbstractSession session) Create the commit manager on the session. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataModificationEvent
(DatabaseMapping mapping, Object[] event) Add the data query to be performed at the end of the commit.void
addDeferredCall
(DatabaseTable table, DatasourceCall call, DatabaseQueryMechanism mechanism) Add the data query to be performed at the end of the commit.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.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.void
deleteAllObjects
(Class<?> theClass, List objects, AbstractSession session) Delete all of the objects with the matching class.void
deleteAllObjects
(List objects) delete all of the objects as a single transaction.Return the order in which objects should be committed to the database.Return the map of states of the objects being committed.protected Map
<DatabaseMapping, List<Object[]>> Used to store data queries to be performed at the end of the commit.protected Map
<DatabaseTable, List<Object[]>> Used to store calls to be performed at the end of the commit.Deletion are cached until the end.protected AbstractSession
Return the session that this is managing commits for.protected Map
Return any objects that have been shallow committed during this commit process.protected boolean
protected boolean
protected boolean
void
Reset the commit order from the session's descriptors.boolean
isActive()
Return if the commit manager is active.boolean
isCommitCompleted
(Object object) Return if the object has been committed.boolean
Return if the object has been committed.boolean
isCommitInPostModify
(Object object) Return if the object is being in progress of being post modify commit.boolean
isCommitInPreModify
(Object objectOrChangeSet) Return if the object is being in progress of being pre modify commit.boolean
isProcessedCommit
(Object object) Return if the object has been processed.boolean
isShallowCommitted
(Object object) Return if the object is shallow committed.void
markCommitCompleted
(Object object) Mark the commit of the object as being fully completed.void
markIgnoreCommit
(Object object) void
markPostModifyCommitInProgress
(Object object) Add an object as being in progress of being committed.void
markPreModifyCommitInProgress
(Object object) Add an object as being in progress of being committed.void
markShallowCommit
(Object object) Mark the object as shallow committed.void
Reset the commits.void
setCommitOrder
(List 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.void
setIsActive
(boolean isActive) Set if the commit manager is active.protected void
setObjectsToDelete
(List 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 shallowCommits) Set any objects that have been shallow committed during this commit process.toString()
Print the in progress depth.
-
Field Details
-
commitOrder
Order based on mapping foreign key constraints on how to insert objects by class. -
commitState
This tracks the commit state for the objects, PENDING, PRE, POST, COMPLETE. The key is the object and the value is the state. -
PRE
The commit is in progress, but the row has not been written. -
POST
The commit is in progress, and the row has been written. -
COMPLETE
The commit is complete for the object. -
IGNORE
This object should be ignored. -
shallowCommits
Set of objects that had partial row written to resolve constraints. -
session
-
isActive
protected boolean isActiveThe commit manager is active while writing a set of objects (UOW), it is not active when writing a single object (DB session). -
dataModifications
Map of modification events used to defer insertion into m-m, dc, join tables. -
deferredCalls
Map of deferred calls groups by their table. This is used to defer multiple table writes for batching and deadlock avoidance. -
objectsToDelete
List of orphaned objects pending deletion. -
commitDepth
protected int commitDepthCounter used to keep track of commit depth for non-UOW writes.
-
-
Constructor Details
-
CommitManager
Create the commit manager on the session. It must be initialized later on after the descriptors have been added.
-
-
Method Details
-
addDataModificationEvent
Add the data query to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock. -
addDeferredCall
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. -
addObjectToDelete
Deletion are cached until the end. -
commitAllObjectsWithChangeSet
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. -
commitAllObjectsForClassWithChangeSet
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. -
commitNewObjectsForClassWithChangeSet
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. -
commitChangedObjectsForClassWithChangeSet
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. -
deleteAllObjects
public void deleteAllObjects(List 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. -
deleteAllObjects
Delete all of the objects with the matching 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. -
getCommitState
Return the map of states of the objects being committed. The states are defined as static Integers (PENDING, PRE, POST, COMPLETE). -
hasDataModifications
protected boolean hasDataModifications() -
getDataModifications
Used to store data queries to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock. -
hasDeferredCalls
protected boolean hasDeferredCalls() -
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. -
hasObjectsToDelete
protected boolean hasObjectsToDelete() -
getObjectsToDelete
Deletion are cached until the end. -
getSession
Return the session that this is managing commits for. -
getShallowCommits
Return any objects that have been shallow committed during this commit process. -
initializeCommitOrder
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. -
isActive
public boolean isActive()Return if the commit manager is active. -
isProcessedCommit
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. -
isCommitCompleted
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. -
isCommitCompletedInPostOrIgnore
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. -
isCommitInPostModify
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. -
isCommitInPreModify
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. -
isShallowCommitted
Return if the object is shallow committed. This is required to resolve bidirectional references. -
markCommitCompleted
Mark the commit of the object as being fully completed. This should be called by any query that has finished writing an object. -
markIgnoreCommit
-
markPostModifyCommitInProgress
Add an object as being in progress of being committed. This should be called by any query that is writing an object. -
markPreModifyCommitInProgress
Add an object as being in progress of being committed. This should be called by any query that is writing an object. -
markShallowCommit
Mark the object as shallow committed. This is required to resolve bidirectional references. -
reinitialize
public void reinitialize()Reset the commits. This must be done before a new commit process is begun. -
setCommitOrder
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. -
setDataModifications
Used to store data queries to be performed at the end of the commit. This is done to decrease dependencies and avoid deadlock. -
setIsActive
public void setIsActive(boolean isActive) Set if the commit manager is active. -
setObjectsToDelete
Deletion are cached until the end. -
setSession
Set the session that this is managing commits for. -
setShallowCommits
Set any objects that have been shallow committed during this commit process. -
toString
Print the in progress depth.
-