Class UnitOfWorkImpl
- All Implemented Interfaces:
Serializable
,Cloneable
,CoreSession<ClassDescriptor,
,Login, Platform, Project, SessionEventManager> CommandProcessor
,Session
,UnitOfWork
- Direct Known Subclasses:
RepeatableWriteUnitOfWork
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.persistence.sessions.UnitOfWork
UnitOfWork.CommitOrderType
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
This member variable contains a copy of all of the clones for this particular UOWWhen in transaction batch read objects must use query local to the unit of work.static final int
Set of objects that were deleted by database cascade delete constraints.protected int
Used during the cloning process to track the recursive depth in.Map of all the clones.As well as used as lookup in merge algorithm for aggregates and othersprotected UnitOfWork.CommitOrderType
Allow updates and deletes to be ordered by id or changes to avoid possible deadlocks.static final int
static final int
protected UnitOfWorkImpl
This is only used for EJB entity beans to manage beans accessed in a transaction context.final long
final long
final String
static final int
Contains deferred ModifyAllQuery's that have translation row for execution only.protected Map
<DatabaseMapping, List<Object>> Stores all of the private owned objects that have been removed and may need to cascade deletionUsed to store deleted objects that have reference to other deleted objects.static final int
Used for Conforming Queriesstatic final int
protected boolean
PERF: Cache isNestedUnitOfWork check.protected MergeManager
Used to store the list of locks that this UnitOfWork has acquired for this mergeprotected int
With the new synchronized unit of work, need a lifecycle state variable to track birth, committed, pending_merge and death.static final String
protected MergeManager
temporarily holds a reference to a merge manager that is calling this UnitOfWork during mergestatic final int
protected List
<ModifyAllQuery> lazy initialization done in storeModifyAllQuery.Stores a map from the clone to the original merged object, as a different instance is used as the original for merges.used to store a list of the new objects in the parentstatic final int
Kept reference of read lock objectsprotected AbstractSession
static final int
use to track pessimistic locked objectsprotected boolean
This attribute records when the preDelete stage of Commit has completedprotected Map
<Object, IdentityHashSet> Map of primary key to list of new objects.protected Map
<DatabaseMapping, Set> Cache references of private owned objects for the removal of private owned orphansstatic final String
Used for read lock to determine update the version field with the same value or increment valuestatic final String
Read-only class can be used for reference data to avoid cloning when not required.protected ReferenceMode
This stored the reference mode for this UOW.protected boolean
True if UnitOfWork should be resumed on completion of transaction.protected boolean
True if the value holder for the joined attribute should be triggered.protected boolean
PERF: Allows discover new objects to be skipped if app always calls persist.protected boolean
Allow for double merges of new objects by putting them into the cache.protected boolean
Flag indicating that deletes should be performed before other updates.protected int
Flag indicating how to deal with exceptions on conforming queries.protected boolean
Determine if does-exist should be performed on persist.protected static boolean
Used for merging dependent values without use of WL SessionAccessorstatic final int
protected Object
PERF: Stores the JTA transaction to optimize activeUnitOfWork lookup.protected UnitOfWorkChangeSet
This method is used to store the current changeSet for this UnitOfWork.Used to store objects already deleted from the db and unregisteredprotected int
The amount of validation can be configured.protected boolean
True if either DataModifyQuery or ModifyAllQuery was executed.protected boolean
Flag indicating that the transaction for this UOW was already begun.static final int
Fields inherited from class org.eclipse.persistence.internal.sessions.AbstractSession
accessors, activeCommandThreads, attributeGroups, broker, commandManager, commitManager, defaultReferenceMode, deferredEvents, descriptors, eventManager, exceptionHandler, externalTransactionController, identityMapAccessor, injectionManager, integrityChecker, isConcurrent, isExecutingEvents, isFinalizersEnabled, isInBroker, isInProfile, isLoggingOff, isSynchronized, jpaQueriesProcessed, lastDescriptorAccessed, logSessionString, metadatalistener, multitenantContextProperties, name, numberOfActiveUnitsOfWork, objectsLockedForClone, partitioningPolicy, pessimisticLockTimeoutDefault, pessimisticLockTimeoutUnitDefault, platform, profiler, project, properties, queries, queryBuilder, queryTimeoutDefault, queryTimeoutUnitDefault, serializer, sessionLog, shouldCheckWriteLock, shouldOptimizeResultSetAccess, shouldPropagateChanges, staticMetamodelClasses, tablePerTenantDescriptors, tablePerTenantQueries, tolerateInvalidJPQL, transactionMutex, wasJTSTransactionInternallyStarted
Fields inherited from interface org.eclipse.persistence.sessions.coordination.CommandProcessor
LOG_DEBUG, LOG_ERROR, LOG_INFO, LOG_WARNING
-
Constructor Summary
ConstructorDescriptionINTERNAL:UnitOfWorkImpl
(AbstractSession parent, ReferenceMode referenceMode) INTERNAL: Create and return a new unit of work with the session as its parent. -
Method Summary
Modifier and TypeMethodDescriptionacquireHistoricalSession
(AsOfClause clause) INTERNAL: Acquires a special historical session for reading objects as of a past time.PUBLIC: Return a nested unit of work for this unit of work.protected void
INTERNAL: Acquire the unit of work cache write locks, if required.void
addDeletedPrivateOwnedObjects
(DatabaseMapping mapping, Object object) INTERNAL: Records a private owned object that has been de-referenced and will need to processed for related private owned objects.void
addDeletionDependency
(Object target, Object source) INTERNAL: Record deleted objects that have reference to other deleted objects.void
addNewAggregate
(Object originalObject) INTERNAL: Register a new aggregate object with the unit of work.protected void
addNewObjectToPrimaryKeyToNewObjects
(Object newObject) INTERNAL: Extracts the primary key from a new object and puts it in primaryKeyToNewObjects.protected void
addNewObjectToPrimaryKeyToNewObjects
(Object newObject, ClassDescriptor descriptor) INTERNAL: Extracts the primary key from a new object and puts it in primaryKeyToNewObjects.void
addObjectDeletedDuringCommit
(Object object, ClassDescriptor descriptor) INTERNAL: Add object deleted during root commit of unit of work.void
addPessimisticLockedClone
(Object clone) INTERNAL:void
addPrivateOwnedObject
(DatabaseMapping mapping, Object privateOwnedObject) INTERNAL: Add a privately owned object to the privateOwnedObjectsMap.void
addReadOnlyClass
(Class<?> theClass) PUBLIC: Adds the given Java class to the receiver's set of read-only classes.void
addReadOnlyClasses
(Collection classes) PUBLIC: Adds the classes in the given Vector to the existing set of read-only classes.void
addRemovedObject
(Object orignal) INTERNAL: Register that an object was removed in a nested unit of work.void
void
INTERNAL: Called after external transaction rolled back.void
assignSequenceNumber
(Object object) ADVANCED: Assign sequence number to the object.assignSequenceNumber
(Object object, ClassDescriptor descriptor) INTERNAL: Assign sequence number to the object.void
ADVANCED: Assign sequence numbers to all new objects registered in this unit of work, or any new objects reference by any objects registered.protected void
assignSequenceNumbers
(Map objects) INTERNAL: Assign sequence numbers to all of the objects.protected void
INTERNAL: Print the objects in the unit of work.void
PUBLIC: Tell the unit of work to begin a transaction now.void
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow.buildOriginal
(Object workingClone) INTERNAL: Unregistered new objects have no original so we must create one for commit and resume and to put into the parent.calculateChanges
(Map registeredObjects, UnitOfWorkChangeSet changeSet, boolean assignSequences, boolean shouldCloneMap) INTERNAL:protected boolean
INTERNAL: Checks whether the receiver has been used.checkExistence
(Object object) INTERNAL: Register the object and return the clone if it is existing otherwise return null if it is new.boolean
INTERNAL: Return if the object is an existing object (but has not been registered), or a new object (that has not be persisted).checkIfAlreadyRegistered
(Object object, ClassDescriptor descriptor) INTERNAL: Return the value of the object if it already is registered, otherwise null.void
clear
(boolean shouldClearCache) INTERNAL: This method will clear all registered objects from this UnitOfWork.void
clearForClose
(boolean shouldClearCache) INTERNAL: Call this method if the uow will no longer be used for committing transactions: all the change sets will be dereferenced, and (optionally) the cache cleared.protected Object
cloneAndRegisterNewObject
(Object original, boolean isShallowClone) ADVANCED: Register the new object with the unit of work.cloneAndRegisterObject
(Object original, CacheKey parentCacheKey, ClassDescriptor descriptor) INTERNAL: Clone and register the object.cloneAndRegisterObject
(Object original, CacheKey parentCacheKey, CacheKey unitOfWorkCacheKey, ClassDescriptor descriptor) INTERNAL: Clone and register the object.protected Map
This method is used internally to clone a map that holds the persistenceContexts.INTERNAL: Prepare for merge in nested uow.void
commit()
PUBLIC: Commit the unit of work to its parent.protected void
INTERNAL: Commits a UnitOfWork where the commit process has already been initiated by all call to writeChanges().void
PUBLIC: Commit the unit of work to its parent.protected void
INTERNAL: Commits and resumes a UnitOfWork where the commit process has already been initiated by all call to writeChanges().void
PUBLIC: Commit the unit of work to its parent.void
commitAndResumeWithPreBuiltChangeSet
(UnitOfWorkChangeSet uowChangeSet) INTERNAL: This method is used by the MappingWorkbench for their read-only file feature this method must not be exposed to or used by customers until it has been revised and the feature revisited to support OptimisticLocking and Serializationprotected boolean
PROTECTED: Used in commit and commit-like methods to commit internally started external transactionprotected void
INTERNAL: Commit the changes to any objects to the parent.void
INTERNAL: Commit the changes to any objects to the parent.void
commitRootUnitOfWorkWithPreBuiltChangeSet
(UnitOfWorkChangeSet uowChangeSet) INTERNAL: This method is used by the MappingWorkbench read-only files feature It will commit a pre-built unitofwork change set to the databaseprotected void
commitToDatabase
(boolean commitTransaction) INTERNAL: CommitChanges To The Database from a calculated changeSetprotected void
commitToDatabaseWithChangeSet
(boolean commitTransaction) INTERNAL: Commit the changes to any objects to the parent.protected void
commitToDatabaseWithPreBuiltChangeSet
(UnitOfWorkChangeSet uowChangeSet, boolean commitTransaction, boolean isChangeSetFromOutsideUOW) INTERNAL: Commit pre-built changeSet to the database changeSet to the database.void
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow.void
INTERNAL: After writeChanges() everything has been done except for committing the transaction.INTERNAL: Copy the read only classes from the unit of work.<T> DatabaseValueHolder
<T> createCloneQueryValueHolder
(ValueHolderInterface<T> attributeValue, Object clone, AbstractRecord row, ForeignReferenceMapping mapping) <T> DatabaseValueHolder
<T> createCloneTransformationValueHolder
(ValueHolderInterface<T> attributeValue, Object original, Object clone, AbstractTransformationMapping mapping) protected Map
This method is used internally to create a map to hold the persistenceContexts.protected Map
createMap
(int size) This method is used internally to create a map to hold the persistenceContexts.deepMergeClone
(Object rmiClone) PUBLIC: Merge the attributes of the clone into the unit of work copy.deepRevertObject
(Object clone) PUBLIC: Revert the object's attributes from the parent.void
deepUnregisterObject
(Object clone) ADVANCED: Unregister the object with the unit of work.protected void
INTERNAL: Search for any objects in the parent that have not been registered.protected void
INTERNAL: Search for any objects in the parent that have not been registered.void
discoverAndPersistUnregisteredNewObjects
(Object object, boolean cascadePersist, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, Set cascadeErrors) INTERNAL: Discover any new objects referenced from registered objects and persist them.void
discoverUnregisteredNewObjects
(Map clones, Map knownNewObjects, Map unregisteredExistingObjects, Map visitedObjects) INTERNAL: Traverse the object to find references to objects not registered in this unit of work.void
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.executeCall
(Call call, AbstractRecord translationRow, DatabaseQuery query) INTERNAL: Override From session.void
forceUpdateToVersionField
(Object lockObject, boolean shouldModifyVersionField) ADVANCED: Set optimistic read lock on the object.INTERNAL: The uow does not store a local accessor but shares its parents.INTERNAL: The uow does not store a local accessor but shares its parents.getAccessors
(Call call, AbstractRecord translationRow, DatabaseQuery query) INTERNAL: Return the connections to use for the query execution.PUBLIC: Return the active unit of work for the current active external (JTS) transaction.getAllFromNewObjects
(Expression selectionCriteria, Class<?> theClass, AbstractRecord translationRow, int valueHolderPolicy) INTERNAL: Return any new objects matching the expression.getBackupClone
(Object clone) INTERNAL: Return the backup clone for the working clone.getBackupClone
(Object clone, ClassDescriptor descriptor) INTERNAL: Return the backup clone for the working clone.getBackupCloneForCommit
(Object clone) INTERNAL: Return the backup clone for the working clone.getBackupCloneForCommit
(Object clone, ClassDescriptor descriptor) INTERNAL: Return the backup clone for the working clone.INTERNAL: When in transaction batch read objects must use query local to the unit of work.INTERNAL: Return any objects have been deleted through database cascade delete constraints.INTERNAL: Return the list of object with changes.INTERNAL: Return the clone mapping.INTERNAL: Map used to avoid garbage collection in weak caches.INTERNAL: The commit manager is used to resolve referential integrity on commits of multiple objects.ADVANCED: Return the commit order.INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.ADVANCED: This method Will Calculate the changes for the UnitOfWork.INTERNAL: Returns the set of read-only classes that gets assigned to each newly created UnitOfWork.INTERNAL: The deleted objects stores any objects removed during the unit of work.INTERNAL: Return deleted objects that have reference to other deleted objects.getDeletionDependencies
(Object deletedObject) INTERNAL: Return references to other deleted objects for this deleted object.getExecutionSession
(DatabaseQuery query) INTERNAL: Gets the session which this query will be executed on.int
INTERNAL: The life cycle tracks if the unit of work is active and is used for JTS.A reference to the last used merge manager.INTERNAL: The map stores any new aggregates that have been cloned.INTERNAL: The stores a map from new object clones to the original object used from merge.INTERNAL: The new objects stores any objects newly created during the unit of work.INTERNAL: The returns the list that will hold the new objects from the Parent UnitOfWorkINTERNAL: The new objects stores any objects newly created during the unit of work.getObjectFromNewObjects
(Class<?> theClass, Object selectionKey) INTERNAL: Return any new object matching the expression.getObjectFromNewObjects
(Expression selectionCriteria, Class<?> theClass, AbstractRecord translationRow, int valueHolderPolicy) INTERNAL: Return any new object matching the expression.INTERNAL: Returns all the objects which are deleted during root commit of unit of work.INTERNAL: Return optimistic read lock objectsgetOriginalVersionOfNewObject
(Object workingClone) INTERNAL: Return the original version of the new object (working clone).getOriginalVersionOfObject
(Object workingClone) ADVANCED: Return the original version of the object(clone) from the parent's identity map.getOriginalVersionOfObjectOrNull
(Object workingClone, ClassDescriptor descriptor) INTERNAL: Return the original version of the object(clone) from the parent's identity map.getOriginalVersionOfObjectOrNull
(Object workingClone, ObjectChangeSet changeSet, ClassDescriptor descriptor, AbstractSession targetSession) INTERNAL: Return the original version of the object(clone) from the parent's identity map.PUBLIC: Return the parent.getParentIdentityMapSession
(ClassDescriptor descriptor, boolean canReturnSelf, boolean terminalOnly) INTERNAL: Returns the appropriate IdentityMap session for this descriptor.INTERNAL:getPlatform
(Class<?> domainClass) INTERNAL: Return the platform for a particular class.INTERNAL: The primaryKeyToNewObjects stores a list of objects for every primary key.getProperty
(String name) INTERNAL: Search for and return the user defined property from this UOW, if it not found then search for the property from parent.PUBLIC: Return the query from the session pre-defined queries with the given name.PUBLIC: Return the query from the session pre-defined queries with the given name.ADVANCED: Returns the set of read-only classes in this UnitOfWork.getReference
(Class<?> theClass, Object id) Get an instance, whose state may be lazily fetched.protected Map
INTERNAL: The removed objects stores any newly registered objects removed during the nested unit of work.INTERNAL: Return the Sequencing object used by the session.INTERNAL: Marked internal as this is not customer API but helper methods for accessing the server platform from within EclipseLink's other sessions types (i.e.INTERNAL: Returns the type of session, its class.int
INTERNAL: Return whether to throw exceptions on conforming queriesint
getState()
INTERNAL: Find out what the lifecycle state of this UoW is in.INTERNAL: PERF: Return the associated external transaction.ADVANCED: Returns the currentChangeSet from the UnitOfWork.INTERNAL: Used to lazy Initialize the unregistered existing Objects collection.protected Map
INTERNAL: This is used to store unregistered objects discovered in the parent so that the child unit of work knows not to register them on commit.protected Map
INTERNAL: This is used to store unregistered objects discovered in the parent so that the child unit of work knows not to register them on commit.int
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.boolean
INTERNAL: Return if any objects have been deleted through database cascade delete constraints.boolean
ADVANCED: The Unit of work is capable of preprocessing to determine if any on the clone have been changed.boolean
INTERNAL: Return if the unit of work has any clones.protected boolean
boolean
INTERNAL: Return if any container beans exist.protected boolean
boolean
INTERNAL: The deleted objects stores any objects removed during the unit of work.protected boolean
INTERNAL: Does this unit of work have any changes or anything that requires a write to the database and a transaction to be started.protected boolean
boolean
INTERNAL: Return if there are any registered new objects.protected boolean
protected boolean
boolean
INTERNAL: Return if there are any optimistic read locks.boolean
INTERNAL: Return true if there are any pessimistic locked objects in this unit of work, false otherwise.boolean
INTERNAL: Return true if privateOwnedObjects is not null and not empty, false otherwise.protected boolean
boolean
INTERNAL: Return if there are any unregistered new objects.void
INTERNAL: Set up the IdentityMapManager.internalExecuteQuery
(DatabaseQuery query, AbstractRecord databaseRow) INTERNAL: Return the results from executing the database query.internalRegisterObject
(Object object, ClassDescriptor descriptor, boolean isShallowClone) INTERNAL: Register the object with the unit of work.boolean
isActive()
PUBLIC: Return if the unit of work is active.boolean
INTERNAL: Has writeChanges() been attempted on this UnitOfWork? It may have either succeeded or failed but either way the UnitOfWork is in a highly restricted state.protected boolean
INTERNAL: Once writeChanges has failed all a user can do really is rollback.boolean
isClassReadOnly
(Class<?> theClass, ClassDescriptor descriptor) INTERNAL: Checks to see if the specified class or descriptor is read-only or not in this UnitOfWork.boolean
isCloneNewObject
(Object clone) INTERNAL: Check if the object is already registered.boolean
isCloneNewObjectFromParent
(Object clone) INTERNAL: Check if the object is already registered in a parent Unit Of Workboolean
INTERNAL: Return if the unit of work is waiting to be committed or in the process of being committed.boolean
isConsideredInvalid
(Object object, CacheKey cacheKey, ClassDescriptor descriptor) INTERNAL: Check if the object is invalid and *should* be refreshed.boolean
isDead()
INTERNAL: Return if the unit of work is dead.boolean
PUBLIC: Return whether the session currently has a database transaction in progress.boolean
INTERNAL: Return if the unit of work is waiting to be merged or in the process of being merged.boolean
PUBLIC: Return whether this session is a nested unit of work or not.boolean
isNewObjectInParent
(Object clone) INTERNAL: This method determines if the specified clone is new in the parent UnitOfWorkboolean
isObjectDeleted
(Object object) INTERNAL: Return if the object has been deleted in this unit of work.boolean
isObjectNew
(Object clone) INTERNAL: This method is used to determine if the clone is a new Object in the UnitOfWorkboolean
isObjectRegistered
(Object clone) ADVANCED: Return whether the clone object is already registered.boolean
isOriginalNewObject
(Object original) INTERNAL: Return whether the original object is new.boolean
isPessimisticLocked
(Object clone) INTERNAL: Return if the clone has been pessimistic locked in this unit of work.boolean
static boolean
INTERNAL: Return the status of smart mergeprotected void
INTERNAL: Will notify all the deferred ModifyAllQuery's (excluding UpdateAllQuery's) and deferred UpdateAllQuery's to execute.void
INTERNAL: For synchronized units of work, dump SQL to database.void
issueSQLbeforeCompletion
(boolean commitTransaction) INTERNAL: For synchronized units of work, dump SQL to database.boolean
PUBLIC: Return if this session is a unit of work.boolean
isUnregisteredExistingObject
(Object object) INTERNAL: Return if the object is a known unregistered existing object.boolean
isUnregisteredNewObjectInParent
(Object originalObject) INTERNAL: Return if the object was existing but not registered in the parent of the nested unit of work.protected void
INTERNAL: BMP and Websphere CMP entities have to be merged if they are registered in the unit of work.protected void
INTERNAL: Merge the changes to all objects to the parent.mergeClone
(Object rmiClone) PUBLIC: Merge the attributes of the clone into the unit of work copy.mergeClone
(Object rmiClone, int cascadeDepth, boolean forRefresh) INTERNAL: Merge the attributes of the clone into the unit of work copy.void
INTERNAL: for synchronized units of work, merge changes into parentmergeCloneWithReferences
(Object rmiClone) PUBLIC: Merge the attributes of the clone into the unit of work copy.mergeCloneWithReferences
(Object rmiClone, int cascadePolicy) PUBLIC: Merge the attributes of the clone into the unit of work copy.mergeCloneWithReferences
(Object rmiClone, int cascadePolicy, boolean forceCascade) INTERNAL: Merge the attributes of the clone into the unit of work copy.mergeCloneWithReferences
(Object rmiClone, MergeManager manager) INTERNAL: Merge the attributes of the clone into the unit of work copy.newInstance
(Class<?> theClass) PUBLIC: Return a new instance of the class registered in this unit of work.void
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.void
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.void
performRemove
(Object toBeDeleted, Map visitedObjects) INTERNAL: This method will perform a delete operation on the provided objects pre-determining the objects that will be deleted by a commit of the UnitOfWork including privately owned objects.void
performRemovePrivateOwnedObjectFromChangeSet
(Object toBeRemoved, Map visitedObjects) INTERNAL: Cascade remove the private owned object from the owned UnitOfWorkChangeSetprotected void
populateAndRegisterObject
(Object original, Object workingClone, CacheKey unitOfWorkCacheKey, CacheKey parentCacheKey, ClassDescriptor descriptor) INTERNAL: This method is called from clone and register.protected void
postMergeChanges
(Set classesChanged) INTERNAL: Remove objects from parent's identity map.protected void
INTERNAL: Remove objects deleted during commit from clone and new object cache so that these are not mergedvoid
PUBLIC: Print the objects in the unit of work.processDeleteObjectQuery
(DeleteObjectQuery deleteQuery) INTERNAL: This method is used to process delete queries that pass through the unitOfWork It is extracted out of the internalExecuteQuery method to reduce duplicationregisterAllObjects
(Collection domainObjects) PUBLIC: Register the objects with the unit of work.registerAllObjects
(Vector domainObjects) PUBLIC: Register the objects with the unit of work.registerExistingObject
(Object existingObject) ADVANCED: Register the existing object with the unit of work.registerExistingObject
(Object existingObject, boolean isFromSharedCache) ADVANCED: Register the existing object with the unit of work.registerExistingObject
(Object objectToRegister, ClassDescriptor descriptor, Object queryPrimaryKey, boolean isFromSharedCache) INTERNAL: Register the existing object with the unit of work.registerNewContainerBean
(Object newObject) INTERNAL: Register the new container bean with the unit of work.registerNewContainerBeanForCMP
(Object newObject) INTERNAL: Register the new Bean with the unit of work.registerNewObject
(Object newObject) ADVANCED: Register the new object with the unit of work.protected Object
registerNewObject
(Object implementation, ClassDescriptor descriptor) INTERNAL: Updated to allow passing in of the object's descriptor Register the new object with the unit of work.protected void
registerNewObjectClone
(Object clone, Object original, ClassDescriptor descriptor) INTERNAL: Register the working copy of a new object and its original.void
registerNewObjectForPersist
(Object newObject, Map visitedObjects) INTERNAL: Register the new object with the unit of work.protected void
registerNewObjectInIdentityMap
(Object clone, Object original, ClassDescriptor descriptor) INTERNAL: Add the new object to the cache if set to.protected void
registerNotRegisteredNewObjectForPersist
(Object newObject, ClassDescriptor descriptor) INTERNAL: Called only by registerNewObjectForPersist method, and only if newObject is not already registered.registerObject
(Object object) PUBLIC: Register the object with the unit of work.protected Object
registerObject
(Object object, ClassDescriptor descriptor) INTERNAL: Allows for calling method to provide the descriptor information for this object.void
registerOriginalNewObjectFromNestedUnitOfWork
(Object originalObject, Object backupClone, Object newInstance, ClassDescriptor descriptor) INTERNAL: Register a new object from a nested unit of work into its parent.void
INTERNAL: Register this UnitOfWork against an external transaction controllervoid
release()
PUBLIC: Release the unit of work.void
INTERNAL: Called in the end of beforeCompletion of external transaction synchronization listener.void
releaseReadConnection
(Accessor connection) INTERNAL: Release the read connection to the read connection pool.void
INTERNAL: Release the unit of work cache write locks, if acquired.void
PUBLIC: Empties the set of read-only classes.void
removeForceUpdateToVersionField
(Object lockObject) ADVANCED: Remove optimistic read lock from the object See forceUpdateToVersionField(Object)protected void
INTERNAL: Extracts the primary key and removes an object from primaryKeyToNewObjects.protected void
removeObjectFromPrimaryKeyToNewObjects
(Object object, Object primaryKey) INTERNAL: Removes an object from primaryKeyToNewObjects.void
removePrivateOwnedObject
(DatabaseMapping mapping, Object privateOwnedObject) INTERNAL: Remove a privately owned object from the privateOwnedObjects Map.void
removeReadOnlyClass
(Class<?> theClass) PUBLIC: Removes a Class from the receiver's set of read-only classes.void
INTERNAL: Resume the unit of work state after a flush, or resume operation.retryQuery
(DatabaseQuery query, AbstractRecord row, DatabaseException databaseException, int retryCount, AbstractSession executionSession) INTERNAL: A query execution failed due to an invalid query.void
PUBLIC: Revert all changes made to any registered object.revertObject
(Object clone) PUBLIC: Revert the object's attributes from the parent.revertObject
(Object clone, int cascadeDepth) INTERNAL: Revert the object's attributes from the parent.void
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow.protected void
rollbackTransaction
(boolean intendedToCommitTransaction) INTERNAL: rollbackTransaction() with a twist for external transactions.scanForConformingInstances
(Expression selectionCriteria, Class<?> referenceClass, AbstractRecord arguments, ObjectLevelReadQuery query) INTERNAL: Scans the UnitOfWork identity map for conforming instances.protected void
setAllClonesCollection
(Map objects) INTERNAL: Used to set the collections of all objects in the UnitOfWork.void
setBatchQueries
(Map<ReadQuery, ReadQuery> batchQueries) INTERNAL: When in transaction batch read objects must use query local to the unit of work.protected void
setCascadeDeleteObjects
(Set<Object> cascadeDeleteObjects) INTERNAL: Set any objects have been deleted through database cascade delete constraints.protected void
setCloneMapping
(Map cloneMapping) INTERNAL: Set the clone mapping.void
ADVANCED: Set the commit order.protected void
setContainerBeans
(Map containerBeans) INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.protected void
setContainerUnitOfWork
(UnitOfWorkImpl containerUnitOfWork) INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.void
setDead()
INTERNAL: set UoW lifecycle state variable to DEATHprotected void
setDeletedObjects
(Map deletedObjects) INTERNAL: The deleted objects stores any objects removed during the unit of work.protected void
setLifecycle
(int lifecycle) INTERNAL: The life cycle tracks if the unit of work is active and is used for JTS.void
setMergeManager
(MergeManager mergeManager) INTERNAL: A reference to the last used merge manager.protected void
setNewObjectsCloneToOriginal
(Map newObjects) INTERNAL: The new objects stores any objects newly created during the unit of work.protected void
setNewObjectsOriginalToClone
(Map newObjects) INTERNAL: The new objects stores any objects newly created during the unit of work.void
setObjectsDeletedDuringCommit
(Map deletedObjects) INTERNAL: Set the objects that have been deleted.void
setParent
(AbstractSession parent) INTERNAL: Set the parent.void
INTERNAL: set UoW lifecycle state variable to PENDING_MERGEvoid
setPreDeleteComplete
(boolean preDeleteComplete) void
setReadOnlyClasses
(List<Class<?>> classes) INTERNAL: Gives a new set of read-only classes to the receiver.protected void
setRemovedObjects
(Map removedObjects) INTERNAL: The removed objects stores any newly registered objects removed during the nested unit of work.void
setResumeUnitOfWorkOnTransactionCompletion
(boolean resumeUnitOfWork) INTERNAL: Set if this UnitofWork should be resumed after the end of the transaction Used when UnitOfWork is synchronized with external transaction controlvoid
setShouldCascadeCloneToJoinedRelationship
(boolean shouldCascadeCloneToJoinedRelationship) INTERNAL: True if the value holder for the joined attribute should be triggered.void
setShouldDiscoverNewObjects
(boolean shouldDiscoverNewObjects) INTERNAL: Set if this UnitofWork should discover new objects on commit.void
setShouldNewObjectsBeCached
(boolean shouldNewObjectsBeCached) ADVANCED: By default new objects are not cached until the exist on the database.void
setShouldPerformDeletesFirst
(boolean shouldPerformDeletesFirst) ADVANCED: By default deletes are performed last in a unit of work.void
setShouldThrowConformExceptions
(int shouldThrowExceptions) ADVANCED: Conforming queries can be set to provide different levels of detail about the exceptions they encounter There are two levels: DO_NOT_THROW_CONFORM_EXCEPTIONS = 0; THROW_ALL_CONFORM_EXCEPTIONS = 1;void
setShouldValidateExistence
(boolean shouldValidateExistence) Set the default to determine if does-exist should be performed on persist.static void
setSmartMerge
(boolean option) INTERNAL: Set smart merge flag.void
setSynchronized
(boolean synched) INTERNAL: Set isSynchronized flag to indicate that this session is a synchronized unit of work.void
setTransaction
(Object transaction) INTERNAL: PERF: Set the associated external transaction.void
setUnitOfWorkChangeSet
(UnitOfWorkChangeSet unitOfWorkChangeSet) INTERNAL: Sets the current UnitOfWork change set to be the one passed in.protected void
setUnregisteredExistingObjects
(Map newUnregisteredExistingObjects) INTERNAL: Used to set the unregistered existing objects vector used when validation has been turned off.protected void
setUnregisteredNewObjects
(Map newObjects) INTERNAL:protected void
setUnregisteredNewObjectsInParent
(Map newObjects) INTERNAL:protected void
INTERNAL: Create the map of primary key to new objects used to speed up in-memory querying.void
setValidationLevel
(int validationLevel) ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.void
setWasNonObjectLevelModifyQueryExecuted
(boolean wasNonObjectLevelModifyQueryExecuted) INTERNAL: True if either DataModifyQuery or ModifyAllQuery was executed.void
setWasTransactionBegunPrematurely
(boolean wasTransactionBegunPrematurely) INTERNAL: Set a flag in the root UOW to indicate that a pess.shallowMergeClone
(Object rmiClone) PUBLIC: Merge the attributes of the clone into the unit of work copy.shallowRevertObject
(Object clone) PUBLIC: Revert the object's attributes from the parent.void
shallowUnregisterObject
(Object clone) ADVANCED: Unregister the object with the unit of work.boolean
INTERNAL: True if the value holder for the joined attribute should be triggered.boolean
INTERNAL: Indicates whether clearForClose method should be called by release method.boolean
INTERNAL: Set if this UnitofWork should discover new objects on commit.boolean
shouldForceReadFromDB
(ObjectBuildingQuery query, Object primaryKey) INTERNAL: Calculate whether we should read directly from the database to the UOW.boolean
ADVANCED: By default new objects are not cached until the exist on the database.boolean
ADVANCED: By default all objects are inserted and updated in the database before any object is deleted.boolean
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not refered in the unit of work cache.boolean
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not refered in the unit of work cache.boolean
ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not refered after commit, ensures that objects from the parent cache are not refered in the unit of work cache.boolean
INTERNAL: Indicates whether readObject should return the object read from the db in case there is no object in uow cache (as opposed to fetching the object from parent's cache).boolean
INTERNAL: Returns true if this UnitofWork should be resumed after the end of the transaction Used when UnitOfWork is synchronized with external transaction controlboolean
INTERNAL: This is a JPA setting that is off by default in regular EclipseLink.boolean
Return the default to determine if does-exist should be performed on persist.void
storeDeferredModifyAllQuery
(DatabaseQuery query, AbstractRecord translationRow) INTERNAL: Store the deferred UpdateAllQuery's from the UoW in the list for execution.void
storeModifyAllQuery
(DatabaseQuery query) INTERNAL: Store the ModifyAllQuery's from the UoW in the list.void
INTERNAL Synchronize the clones and update their backup copies.protected void
undeleteObject
(Object object) INTERNAL: This method is used to transition an object from the deleted objects list to be simply be register.void
unregisterObject
(Object clone) PUBLIC: Unregister the object with the unit of work.void
unregisterObject
(Object clone, int cascadeDepth) INTERNAL: Unregister the object with the unit of work.void
unregisterObject
(Object clone, int cascadeDepth, boolean forDetach) INTERNAL: Unregister the object with the unit of work.void
updateChangeTrackersIfRequired
(Object objectToWrite, ObjectChangeSet changeSetToWrite, UnitOfWorkImpl uow, ClassDescriptor descriptor) INTERNAL: This method is used internally to update the tracked objects if requiredprotected Object
updateDerivedIds
(Object clone, ClassDescriptor descriptor) INTERNAL: On persist and flush operations we must update any derived id fields.void
ADVANCED: This can be used to help debugging an object-space corruption.boolean
INTERNAL: 272022: Avoid releasing locks on the wrong server thread.boolean
wasDeleted
(Object original) INTERNAL: Return if the object was deleted previously (in a flush).boolean
INTERNAL: True if either DataModifyQuery or ModifyAllQuery was executed.boolean
INTERNAL: Indicates if a transaction was begun by a pessimistic locking or non-selecting query.void
ADVANCED: Writes all changes now before commit().void
INTERNAL: This method notifies the accessor that a particular sets of writes has completed.Methods inherited from class org.eclipse.persistence.internal.sessions.AbstractSession
acquireNonSynchronizedUnitOfWork, acquireNonSynchronizedUnitOfWork, acquireRepeatableWriteUnitOfWork, acquireUnitOfWork, addAlias, addJPAQuery, addJPATablePerTenantQuery, addMultitenantContextProperty, addQuery, addQuery, addQuery, addStaticMetamodelClass, addTablePerTenantDescriptor, addTablePerTenantQuery, basicBeginTransaction, basicBeginTransaction, basicCommitTransaction, basicExecuteCall, basicRollbackTransaction, beginExternalTransaction, buildDefaultQueryBuilder, checkAndRefreshInvalidObject, checkHierarchyForDescriptor, cleanUpInjectionManager, clearDescriptors, clearIntegrityChecker, clearLastDescriptorAccessed, clearProfile, clone, commitExternalTransaction, compareObjects, compareObjectsDontMatch, config, containsQuery, copy, copy, copyDescriptorNamedQueries, copyDescriptorsFromProject, copyInternal, createInjectionManager, createProtectedInstanceFromCachedData, deferEvent, deleteAllObjects, deleteObject, doesObjectExist, dontLogMessages, endOperationProfile, endOperationProfile, executeDeferredEvents, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, fine, finer, finest, getActiveCommandThreads, getActiveSession, getAliasDescriptors, getAllQueries, getAsOfClause, getAttributeGroups, getBroker, getCacheKeyFromTargetSessionForMerge, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getCommandManager, getDatasourceLogin, getDatasourcePlatform, getDefaultReferenceMode, getDescriptor, getDescriptor, getDescriptorForAlias, getDescriptors, getEventManager, getExceptionHandler, getExceptionHandlerClass, getExternalTransactionController, getId, getIdentityMapAccessor, getIdentityMapAccessorInstance, getInjectionManager, getIntegrityChecker, getJPAQueries, getJPATablePerTenantQueries, getLoader, getLog, getLogin, getLogLevel, getLogLevel, getLogSessionString, getMappedSuperclass, getMultitenantContextProperties, getName, getNextQueryId, getNextSequenceNumberValue, getNumberOfActiveUnitsOfWork, getParentIdentityMapSession, getParentIdentityMapSession, getPartitioningPolicy, getPessimisticLockTimeoutDefault, getPessimisticLockTimeoutUnitDefault, getPlatform, getProfiler, getProject, getProperties, getQueries, getQuery, getQuery, getQueryBuilder, getQueryTimeoutDefault, getQueryTimeoutUnitDefault, getRefreshMetadataListener, getRootSession, getSerializer, getSessionForClass, getSessionForName, getSessionLog, getStaticMetamodelClass, getTablePerTenantDescriptors, getTablePerTenantQueries, getTransactionMutex, handleException, handleSevere, hasBroker, hasCommitManager, hasDescriptor, hasEventManager, hasExceptionHandler, hasExternalTransactionController, hasProperties, hasTablePerTenantDescriptors, hasTablePerTenantQueries, incrementProfile, incrementProfile, info, insertObject, isBroker, isClassReadOnly, isClientSession, isConcurrent, isConnected, isDatabaseSession, isDistributedSession, isExclusiveConnectionRequired, isExclusiveIsolatedClientSession, isFinalizersEnabled, isHistoricalSession, isInBroker, isInProfile, isIsolatedClientSession, isJPAQueriesProcessed, isLoggingOff, isProtectedSession, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isSynchronized, keyFromObject, load, load, log, log, log, log, log, log, log, log, logMessage, logMessage, logThrowable, postAcquireConnection, prepareDatabaseQuery, preReleaseConnection, priviledgedExecuteNonSelectingCall, priviledgedExecuteSelectingCall, processCommand, processJPAQueries, processJPAQuery, readAllObjects, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, readObject, refreshAndLockObject, refreshAndLockObject, refreshObject, registerFinalizer, releaseConnectionAfterCall, releaseUnitOfWork, removeProperty, removeQuery, removeQuery, retrieveCacheKey, retryTransaction, rollbackExternalTransaction, setAccessor, setBroker, setCommandManager, setCommitManager, setDatasourceLogin, setDefaultReferenceMode, setEventManager, setExceptionHandler, setExternalTransactionController, setInjectionManager, setIntegrityChecker, setIsConcurrent, setIsFinalizersEnabled, setIsInBroker, setIsInProfile, setJPAQueriesProcessed, setLog, setLoggingOff, setLogin, setLogin, setLogLevel, setName, setNumberOfActiveUnitsOfWork, setPartitioningPolicy, setPessimisticLockTimeoutDefault, setPessimisticLockTimeoutUnitDefault, setProfiler, setProject, setProperties, setProperty, setQueries, setQueryBuilder, setQueryTimeoutDefault, setQueryTimeoutUnitDefault, setRefreshMetadataListener, setSerializer, setSessionLog, setShouldOptimizeResultSetAccess, setShouldPropagateChanges, setTolerateInvalidJPQL, setTransactionMutex, setWasJTSTransactionInternallyStarted, severe, shouldDisplayData, shouldLog, shouldLogMessages, shouldLogMessages, shouldOptimizeResultSetAccess, shouldPropagateChanges, shouldTolerateInvalidJPQL, startOperationProfile, startOperationProfile, toString, unwrapObject, updateObject, updateProfile, updateTablePerTenantDescriptors, validateCache, validateQuery, verifyDelete, warning, wasJTSTransactionInternallyStarted, wrapObject, writeAllObjectsWithChangeSet, writeObject
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.persistence.sessions.Session
acquireUnitOfWork, addJPAQuery, addQuery, clearIntegrityChecker, clearProfile, containsQuery, copy, copy, doesObjectExist, dontLogMessages, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, getActiveSession, getAsOfClause, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getDatasourceLogin, getDatasourcePlatform, getDefaultReferenceMode, getDescriptor, getDescriptor, getDescriptorForAlias, getDescriptors, getEventManager, getExceptionHandler, getExternalTransactionController, getId, getIdentityMapAccessor, getIntegrityChecker, getJPAQueries, getLog, getLogin, getLogLevel, getLogLevel, getName, getNextSequenceNumberValue, getPartitioningPolicy, getPlatform, getProfiler, getProject, getProperties, getQueries, getQuery, getSerializer, getSessionLog, handleException, handleSevere, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, isClientSession, isConnected, isDatabaseSession, isDistributedSession, isFinalizersEnabled, isInProfile, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, log, logMessage, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, refreshObject, removeProperty, removeQuery, setDefaultReferenceMode, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setIsFinalizersEnabled, setLog, setLogLevel, setName, setPartitioningPolicy, setProfiler, setProperty, setQueryTimeoutDefault, setQueryTimeoutUnitDefault, setSerializer, setSessionLog, shouldLog, shouldLogMessages, validateCache
Methods inherited from interface org.eclipse.persistence.sessions.UnitOfWork
deleteAllObjects, deleteObject, isClassReadOnly, refreshAndLockObject, refreshAndLockObject
-
Field Details
-
CREATION_THREAD_ID
public final long CREATION_THREAD_ID -
CREATION_THREAD_NAME
-
CREATION_THREAD_HASHCODE
public final long CREATION_THREAD_HASHCODE -
cloneToOriginals
As well as used as lookup in merge algorithm for aggregates and others -
parent
-
cloneMapping
Map of all the clones. The key contains the clone of the object. -
newObjectsCloneToOriginal
-
newObjectsOriginalToClone
-
Map of primary key to list of new objects. Used to speedup in-memory querying.
-
newObjectsCloneToMergeOriginal
Stores a map from the clone to the original merged object, as a different instance is used as the original for merges. -
deletedObjects
-
allClones
This member variable contains a copy of all of the clones for this particular UOW -
objectsDeletedDuringCommit
-
removedObjects
-
unregisteredNewObjects
-
unregisteredNewObjectsInParent
-
unregisteredExistingObjects
-
newObjectsInParentOriginalToClone
-
privateOwnedObjects
Cache references of private owned objects for the removal of private owned orphans -
newObjectsInParent
used to store a list of the new objects in the parent -
newAggregates
-
unitOfWorkChangeSet
This method is used to store the current changeSet for this UnitOfWork. -
containerUnitOfWork
This is only used for EJB entity beans to manage beans accessed in a transaction context. -
containerBeans
-
pessimisticLockedObjects
use to track pessimistic locked objects -
lastUsedMergeManager
Used to store the list of locks that this UnitOfWork has acquired for this merge -
batchQueries
When in transaction batch read objects must use query local to the unit of work. -
readOnlyClasses
Read-only class can be used for reference data to avoid cloning when not required. -
wasTransactionBegunPrematurely
protected boolean wasTransactionBegunPrematurelyFlag indicating that the transaction for this UOW was already begun. -
shouldNewObjectsBeCached
protected boolean shouldNewObjectsBeCachedAllow for double merges of new objects by putting them into the cache. -
shouldPerformDeletesFirst
protected boolean shouldPerformDeletesFirstFlag indicating that deletes should be performed before other updates. -
shouldThrowConformExceptions
protected int shouldThrowConformExceptionsFlag indicating how to deal with exceptions on conforming queries. -
validationLevel
protected int validationLevelThe amount of validation can be configured. -
None
public static final int None- See Also:
-
Partial
public static final int Partial- See Also:
-
Full
public static final int Full- See Also:
-
lifecycle
protected int lifecycleWith the new synchronized unit of work, need a lifecycle state variable to track birth, committed, pending_merge and death. -
Birth
public static final int Birth- See Also:
-
CommitPending
public static final int CommitPending- See Also:
-
CommitTransactionPending
public static final int CommitTransactionPending- See Also:
-
WriteChangesFailed
public static final int WriteChangesFailed- See Also:
-
MergePending
public static final int MergePending- See Also:
-
Death
public static final int Death- See Also:
-
AfterExternalTransactionRolledBack
public static final int AfterExternalTransactionRolledBack- See Also:
-
DO_NOT_THROW_CONFORM_EXCEPTIONS
public static final int DO_NOT_THROW_CONFORM_EXCEPTIONSUsed for Conforming Queries- See Also:
-
THROW_ALL_CONFORM_EXCEPTIONS
public static final int THROW_ALL_CONFORM_EXCEPTIONS- See Also:
-
LOCK_QUERIES_PROPERTY
- See Also:
-
SmartMerge
protected static boolean SmartMergeUsed for merging dependent values without use of WL SessionAccessor -
optimisticReadLockObjects
Kept reference of read lock objects -
ReadLockOnly
Used for read lock to determine update the version field with the same value or increment value- See Also:
-
ReadLockUpdateVersion
- See Also:
-
modifyAllQueries
lazy initialization done in storeModifyAllQuery. For UpdateAllQuery, only clones of all UpdateAllQuery's (deferred and non-deferred) are stored here for validation only. -
deferredModifyAllQueries
Contains deferred ModifyAllQuery's that have translation row for execution only. At commit their clones will be added to modifyAllQueries for validation afterwards. Array of the query (ModifyAllQuery) and translationRow (AbstractRecord). -
cloneDepth
protected int cloneDepthUsed during the cloning process to track the recursive depth in. This will be used to determine at which point the process can begin to wait on locks without being concerned about creating deadlock situations. -
transaction
PERF: Stores the JTA transaction to optimize activeUnitOfWork lookup. -
resumeOnTransactionCompletion
protected boolean resumeOnTransactionCompletionTrue if UnitOfWork should be resumed on completion of transaction. Used when UnitOfWork is Synchronized with external transaction control -
shouldDiscoverNewObjects
protected boolean shouldDiscoverNewObjectsPERF: Allows discover new objects to be skipped if app always calls persist. -
wasNonObjectLevelModifyQueryExecuted
protected boolean wasNonObjectLevelModifyQueryExecutedTrue if either DataModifyQuery or ModifyAllQuery was executed. Gets reset on commit, effects DoesExistQuery behavior and reading. -
shouldCascadeCloneToJoinedRelationship
protected boolean shouldCascadeCloneToJoinedRelationshipTrue if the value holder for the joined attribute should be triggered. Required by ejb30 fetch join. -
isNestedUnitOfWork
protected boolean isNestedUnitOfWorkPERF: Cache isNestedUnitOfWork check. -
shouldValidateExistence
protected boolean shouldValidateExistenceDetermine if does-exist should be performed on persist. -
commitOrder
Allow updates and deletes to be ordered by id or changes to avoid possible deadlocks. -
referenceMode
This stored the reference mode for this UOW. If the reference mode is weak then this unit of work will retain only weak references to non new, non-deleted objects allowing for garbage collection. If ObjectChangeTracking is used then any objects with changes will not be garbage collected. -
changeTrackedHardList
-
unregisteredDeletedObjectsCloneToBackupAndOriginal
Used to store objects already deleted from the db and unregistered -
preDeleteComplete
protected boolean preDeleteCompleteThis attribute records when the preDelete stage of Commit has completed -
deletedPrivateOwnedObjects
Stores all of the private owned objects that have been removed and may need to cascade deletion -
mergeManagerForActiveMerge
temporarily holds a reference to a merge manager that is calling this UnitOfWork during merge -
cascadeDeleteObjects
Set of objects that were deleted by database cascade delete constraints. -
deletionDependencies
Used to store deleted objects that have reference to other deleted objects. This is need to delete cycles of objects in the correct order.
-
-
Constructor Details
-
UnitOfWorkImpl
public UnitOfWorkImpl()INTERNAL: -
UnitOfWorkImpl
INTERNAL: Create and return a new unit of work with the session as its parent.
-
-
Method Details
-
acquireHistoricalSession
INTERNAL: Acquires a special historical session for reading objects as of a past time.- Specified by:
acquireHistoricalSession
in interfaceSession
- Overrides:
acquireHistoricalSession
in classAbstractSession
- Parameters:
clause
- Represents a valid snap shot time.- Throws:
ValidationException
- ifthis
not a ClientSession, plain Session, or SessionBroker.- See Also:
-
acquireUnitOfWork
PUBLIC: Return a nested unit of work for this unit of work. A nested unit of work can be used to isolate a subset of work on the unit of work, such as a dialog being open from an editor. The nested unit of work will only commit change to its objects to its parent unit of work, not the database. Only the parent unit of work will commit to the database.- Specified by:
acquireUnitOfWork
in interfaceSession
- Overrides:
acquireUnitOfWork
in classAbstractSession
- See Also:
-
addDeletedPrivateOwnedObjects
INTERNAL: Records a private owned object that has been de-referenced and will need to processed for related private owned objects. -
addNewAggregate
INTERNAL: Register a new aggregate object with the unit of work. -
addObjectDeletedDuringCommit
INTERNAL: Add object deleted during root commit of unit of work. -
addReadOnlyClass
PUBLIC: Adds the given Java class to the receiver's set of read-only classes. Cannot be called after objects have been registered in the unit of work.- Specified by:
addReadOnlyClass
in interfaceUnitOfWork
- Throws:
ValidationException
-
addReadOnlyClasses
PUBLIC: Adds the classes in the given Vector to the existing set of read-only classes. Cannot be called after objects have been registered in the unit of work.- Specified by:
addReadOnlyClasses
in interfaceUnitOfWork
-
addRemovedObject
INTERNAL: Register that an object was removed in a nested unit of work. -
assignSequenceNumber
ADVANCED: Assign sequence number to the object. This allows for an object's id to be assigned before commit. It can be used if the application requires to use the object id before the object exists on the database. Normally all ids are assigned during the commit automatically.- Specified by:
assignSequenceNumber
in interfaceUnitOfWork
- Throws:
DatabaseException
-
assignSequenceNumber
public Object assignSequenceNumber(Object object, ClassDescriptor descriptor) throws DatabaseException INTERNAL: Assign sequence number to the object.- Throws:
DatabaseException
-
assignSequenceNumbers
ADVANCED: Assign sequence numbers to all new objects registered in this unit of work, or any new objects reference by any objects registered. This allows for an object's id to be assigned before commit. It can be used if the application requires to use the object id before the object exists on the database. Normally all ids are assigned during the commit automatically.- Specified by:
assignSequenceNumbers
in interfaceUnitOfWork
- Throws:
DatabaseException
-
assignSequenceNumbers
INTERNAL: Assign sequence numbers to all of the objects. This allows for an object's id to be assigned before commit. It can be used if the application requires to use the object id before the object exists on the database. Normally all ids are assigned during the commit automatically.- Throws:
DatabaseException
-
beginEarlyTransaction
PUBLIC: Tell the unit of work to begin a transaction now. By default the unit of work will begin a transaction at commit time. The default is the recommended approach, however sometimes it is necessary to start the transaction before commit time. When the unit of work commits, this transaction will be committed.- Specified by:
beginEarlyTransaction
in interfaceUnitOfWork
- Throws:
DatabaseException
- See Also:
-
beginTransaction
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow. The uow shares its parents transactions.- Overrides:
beginTransaction
in classAbstractSession
- Throws:
DatabaseException
- if the database connection is lost or the begin is rejected.- See Also:
-
buildOriginal
INTERNAL: Unregistered new objects have no original so we must create one for commit and resume and to put into the parent. We can NEVER let the same copy of an object exist in multiple units of work. -
calculateChanges
public UnitOfWorkChangeSet calculateChanges(Map registeredObjects, UnitOfWorkChangeSet changeSet, boolean assignSequences, boolean shouldCloneMap) INTERNAL:This calculates changes in two passes, first on registered objects, second it discovers unregistered new objects on only those objects that changed, and calculates their changes. This also assigns sequence numbers to new objects.
-
canChangeReadOnlySet
protected boolean canChangeReadOnlySet()INTERNAL: Checks whether the receiver has been used. i.e. objects have been registered.- Returns:
- true or false depending on whether the read-only set can be changed or not.
-
checkForUnregisteredExistingObject
INTERNAL: Return if the object is an existing object (but has not been registered), or a new object (that has not be persisted). -
checkExistence
INTERNAL: Register the object and return the clone if it is existing otherwise return null if it is new. The unit of work determines existence during registration, not during the commit. -
checkIfAlreadyRegistered
INTERNAL: Return the value of the object if it already is registered, otherwise null. -
isConsideredInvalid
INTERNAL: Check if the object is invalid and *should* be refreshed. This is used to ensure that no invalid objects are cloned.- Overrides:
isConsideredInvalid
in classAbstractSession
-
cloneAndRegisterNewObject
ADVANCED: Register the new object with the unit of work. This will register the new object with cloning. Normally the registerObject method should be used for all registration of new and existing objects. This version of the register method can only be used for new objects. This method should only be used if a new object is desired to be registered without an existence Check.- See Also:
-
cloneAndRegisterObject
public Object cloneAndRegisterObject(Object original, CacheKey parentCacheKey, ClassDescriptor descriptor) INTERNAL: Clone and register the object. The cache key must the cache key from the session cache, as it will be used for locking. The unit of work cache key is passed to the normal cloneAndRegisterObject method. -
cloneAndRegisterObject
public Object cloneAndRegisterObject(Object original, CacheKey parentCacheKey, CacheKey unitOfWorkCacheKey, ClassDescriptor descriptor) INTERNAL: Clone and register the object. The cache key must the cache key from the session cache, as it will be used for locking. -
collectAndPrepareObjectsForNestedMerge
INTERNAL: Prepare for merge in nested uow. -
commit
PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, and the unit of work will be released. If the commit is successful the unit of work is released, and a new unit of work must be acquired if further changes are desired.- Specified by:
commit
in interfaceUnitOfWork
- Throws:
DatabaseException
OptimisticLockException
- See Also:
-
commitAndResume
PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, and the unit of work will be released. The normal commit releases the unit of work, forcing a new one to be acquired if further changes are desired. The resuming feature allows for the same unit of work (and working copies) to be continued to be used.- Specified by:
commitAndResume
in interfaceUnitOfWork
- Throws:
DatabaseException
OptimisticLockException
- See Also:
-
commitAndResumeWithPreBuiltChangeSet
public void commitAndResumeWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet) throws DatabaseException, OptimisticLockException INTERNAL: This method is used by the MappingWorkbench for their read-only file feature this method must not be exposed to or used by customers until it has been revised and the feature revisited to support OptimisticLocking and Serialization -
commitAndResumeOnFailure
PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, but the unit of work will remain active. It can then be retried or released. The normal commit failure releases the unit of work, forcing a new one to be acquired if further changes are desired. The resuming feature allows for the same unit of work (and working copies) to be continued to be used if an error occurs. The UnitOfWork will also remain active if the commit is successful.- Specified by:
commitAndResumeOnFailure
in interfaceUnitOfWork
- Throws:
DatabaseException
OptimisticLockException
- See Also:
-
commitAfterWriteChanges
protected void commitAfterWriteChanges()INTERNAL: Commits a UnitOfWork where the commit process has already been initiated by all call to writeChanges().a.k.a finalizeCommit()
-
commitAndResumeAfterWriteChanges
protected void commitAndResumeAfterWriteChanges()INTERNAL: Commits and resumes a UnitOfWork where the commit process has already been initiated by all call to writeChanges().a.k.a finalizeCommit()
-
commitInternallyStartedExternalTransaction
protected boolean commitInternallyStartedExternalTransaction()PROTECTED: Used in commit and commit-like methods to commit internally started external transaction -
commitNestedUnitOfWork
protected void commitNestedUnitOfWork()INTERNAL: Commit the changes to any objects to the parent. -
commitRootUnitOfWork
INTERNAL: Commit the changes to any objects to the parent. -
commitRootUnitOfWorkWithPreBuiltChangeSet
public void commitRootUnitOfWorkWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet) throws DatabaseException, OptimisticLockException INTERNAL: This method is used by the MappingWorkbench read-only files feature It will commit a pre-built unitofwork change set to the database -
commitToDatabase
protected void commitToDatabase(boolean commitTransaction) INTERNAL: CommitChanges To The Database from a calculated changeSet- Parameters:
commitTransaction
- false if called by writeChanges as intent is not to finalize the transaction.
-
commitToDatabaseWithChangeSet
protected void commitToDatabaseWithChangeSet(boolean commitTransaction) throws DatabaseException, OptimisticLockException INTERNAL: Commit the changes to any objects to the parent.- Parameters:
commitTransaction
- false if called by writeChanges as intent is not to finalize the transaction.- Throws:
DatabaseException
OptimisticLockException
-
commitToDatabaseWithPreBuiltChangeSet
protected void commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet, boolean commitTransaction, boolean isChangeSetFromOutsideUOW) throws DatabaseException, OptimisticLockException INTERNAL: Commit pre-built changeSet to the database changeSet to the database. -
commitTransaction
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow. The uow shares its parents transactions.- Overrides:
commitTransaction
in classAbstractSession
- Throws:
DatabaseException
- most databases validate changes as they are done, normally errors do not occur on commit unless the disk fails or the connection is lost.
-
commitTransactionAfterWriteChanges
public void commitTransactionAfterWriteChanges()INTERNAL: After writeChanges() everything has been done except for committing the transaction. This allows that execution path to 'catch up'. -
acquireWriteLocks
protected void acquireWriteLocks()INTERNAL: Acquire the unit of work cache write locks, if required. -
releaseWriteLocks
public void releaseWriteLocks()INTERNAL: Release the unit of work cache write locks, if acquired. -
copyReadOnlyClasses
INTERNAL: Copy the read only classes from the unit of work.- Overrides:
copyReadOnlyClasses
in classAbstractSession
-
deepMergeClone
PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization or other serialization mechanisms, because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. Everything connected to this object (i.e. the entire object tree where rmiClone is the root) is also merged.- Specified by:
deepMergeClone
in interfaceUnitOfWork
- Returns:
- the registered version for the clone being merged.
- See Also:
-
deepRevertObject
PUBLIC: Revert the object's attributes from the parent. This reverts everything the object references.- Specified by:
deepRevertObject
in interfaceUnitOfWork
- Returns:
- the object reverted.
- See Also:
-
deepUnregisterObject
ADVANCED: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. The method should be used carefully because it will delete all the reachable parts.- Specified by:
deepUnregisterObject
in interfaceUnitOfWork
-
discoverAllUnregisteredNewObjects
protected void discoverAllUnregisteredNewObjects()INTERNAL: Search for any objects in the parent that have not been registered. These are required so that the nested unit of work does not add them to the parent clone mapping on commit, causing possible incorrect insertions if they are dereferenced. -
discoverAllUnregisteredNewObjectsInParent
protected void discoverAllUnregisteredNewObjectsInParent()INTERNAL: Search for any objects in the parent that have not been registered. These are required so that the nested unit of work does not add them to the parent clone mapping on commit, causing possible incorrect insertions if they are dereferenced. -
discoverUnregisteredNewObjects
public void discoverUnregisteredNewObjects(Map clones, Map knownNewObjects, Map unregisteredExistingObjects, Map visitedObjects) INTERNAL: Traverse the object to find references to objects not registered in this unit of work. -
dontPerformValidation
public void dontPerformValidation()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
dontPerformValidation
in interfaceUnitOfWork
-
executeCall
public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException INTERNAL: Override From session. Get the accessor based on the query, and execute call, this is here for session broker.- Overrides:
executeCall
in classAbstractSession
- Throws:
DatabaseException
-
forceUpdateToVersionField
ADVANCED: Set optimistic read lock on the object. This feature is override by normal optimistic lock. when the object is changed in UnitOfWork. The cloneFromUOW must be the clone of from this UnitOfWork and it must implements version locking or timestamp locking. The SQL would look like the followings. If shouldModifyVersionField is true, "UPDATE EMPLOYEE SET VERSION = 2 WHERE EMP_ID = 9 AND VERSION = 1" If shouldModifyVersionField is false, "UPDATE EMPLOYEE SET VERSION = 1 WHERE EMP_ID = 9 AND VERSION = 1"- Specified by:
forceUpdateToVersionField
in interfaceUnitOfWork
-
getAccessor
INTERNAL: The uow does not store a local accessor but shares its parents.- Overrides:
getAccessor
in classAbstractSession
-
getAccessors
INTERNAL: The uow does not store a local accessor but shares its parents.- Overrides:
getAccessors
in classAbstractSession
-
getCommitManager
INTERNAL: The commit manager is used to resolve referential integrity on commits of multiple objects. The commit manage is lazy init from parent.- Overrides:
getCommitManager
in classAbstractSession
-
getAccessors
public Collection<Accessor> getAccessors(Call call, AbstractRecord translationRow, DatabaseQuery query) INTERNAL: Return the connections to use for the query execution.- Overrides:
getAccessors
in classAbstractSession
-
getActiveUnitOfWork
PUBLIC: Return the active unit of work for the current active external (JTS) transaction. This should only be used with JTS and will return null if no external transaction exists.- Specified by:
getActiveUnitOfWork
in interfaceSession
- Overrides:
getActiveUnitOfWork
in classAbstractSession
-
getAllFromNewObjects
public Vector getAllFromNewObjects(Expression selectionCriteria, Class<?> theClass, AbstractRecord translationRow, int valueHolderPolicy) INTERNAL: Return any new objects matching the expression. Used for in-memory querying. -
getBackupClone
INTERNAL: Return the backup clone for the working clone.- Throws:
QueryException
-
getBackupClone
INTERNAL: Return the backup clone for the working clone.- Throws:
QueryException
-
getBackupCloneForCommit
INTERNAL: Return the backup clone for the working clone. -
getBackupCloneForCommit
INTERNAL: Return the backup clone for the working clone. -
getCurrentChanges
ADVANCED: This method Will Calculate the changes for the UnitOfWork. Without assigning sequence numbers This is a computationally intensive operation and should be avoided unless necessary. A valid changeSet, with sequencenumbers can be collected from the UnitOfWork after the commit is complete by calling unitOfWork.getUnitOfWorkChangeSet()- Specified by:
getCurrentChanges
in interfaceUnitOfWork
-
getParentIdentityMapSession
public AbstractSession getParentIdentityMapSession(ClassDescriptor descriptor, boolean canReturnSelf, boolean terminalOnly) INTERNAL: Returns the appropriate IdentityMap session for this descriptor. Sessions can be chained and each session can have its own Cache/IdentityMap. Entities can be stored at different levels based on Cache Isolation. This method will return the correct Session for a particular Entity class based on the Isolation Level and the attributes provided.- Overrides:
getParentIdentityMapSession
in classAbstractSession
- Parameters:
canReturnSelf
- true when method calls itself. If the path starting atthis
is acceptable. Sometimes true if want to move to the first valid session, i.e. executing on ClientSession when really should be on ServerSession.terminalOnly
- return the last session in the chain where the Enitity is stored.- Returns:
- Session with the required IdentityMap
-
getExecutionSession
INTERNAL: Gets the session which this query will be executed on. Generally will be called immediately before the call is translated, which is immediately before session.executeCall.Since the execution session also knows the correct datasource platform to execute on, it is often used in the mappings where the platform is needed for type conversion, or where calls are translated.
Is also the session with the accessor. Will return a ClientSession if it is in transaction and has a write connection.
- Overrides:
getExecutionSession
in classAbstractSession
- Parameters:
query
- may store session name or reference class for brokers case- Returns:
- a session with a live accessor
-
getCloneMapping
INTERNAL: Return the clone mapping. The clone mapping contains clone of all registered objects, this is required to store the original state of the objects when registered so that only what is changed will be committed to the database and the parent, (this is required to support parallel unit of work). -
hasCloneMapping
public boolean hasCloneMapping()INTERNAL: Return if the unit of work has any clones. -
getCloneToOriginals
INTERNAL: Map used to avoid garbage collection in weak caches. Also, map used as lookup when originals used for merge when original in identitymap can not be found. As in a CacheIdentityMap -
hasCloneToOriginals
protected boolean hasCloneToOriginals() -
getContainerBeans
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context. -
hasContainerBeans
public boolean hasContainerBeans()INTERNAL: Return if any container beans exist. PERF: Used to avoid lazy initialization of getContainerBeans(). -
getCascadeDeleteObjects
INTERNAL: Return any objects have been deleted through database cascade delete constraints. -
setCascadeDeleteObjects
INTERNAL: Set any objects have been deleted through database cascade delete constraints. -
hasCascadeDeleteObjects
public boolean hasCascadeDeleteObjects()INTERNAL: Return if any objects have been deleted through database cascade delete constraints. -
hasUnregisteredNewObjects
public boolean hasUnregisteredNewObjects()INTERNAL: Return if there are any unregistered new objects. PERF: Used to avoid initialization of new objects map unless required. -
hasNewObjects
public boolean hasNewObjects()INTERNAL: Return if there are any registered new objects. This is used for both newObjectsOriginalToClone and newObjectsCloneToOriginal as they are always in synch. PERF: Used to avoid initialization of new objects map unless required. -
getContainerUnitOfWork
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context. -
getDefaultReadOnlyClasses
INTERNAL: Returns the set of read-only classes that gets assigned to each newly created UnitOfWork.- Overrides:
getDefaultReadOnlyClasses
in classAbstractSession
- See Also:
-
getDeletedObjects
INTERNAL: The deleted objects stores any objects removed during the unit of work. On commit they will all be removed from the database. -
hasDeletedObjects
public boolean hasDeletedObjects()INTERNAL: The deleted objects stores any objects removed during the unit of work. On commit they will all be removed from the database. -
getLifecycle
public int getLifecycle()INTERNAL: The life cycle tracks if the unit of work is active and is used for JTS. -
getMergeManager
A reference to the last used merge manager. This is used to track locked objects. -
getNewAggregates
INTERNAL: The map stores any new aggregates that have been cloned. -
getNewObjectsCloneToOriginal
INTERNAL: The new objects stores any objects newly created during the unit of work. On commit they will all be inserted into the database. -
getPrimaryKeyToNewObjects
INTERNAL: The primaryKeyToNewObjects stores a list of objects for every primary key. It is used to speed up in-memory-querying. -
getNewObjectsCloneToMergeOriginal
INTERNAL: The stores a map from new object clones to the original object used from merge. -
getNewObjectsInParentOriginalToClone
INTERNAL: The returns the list that will hold the new objects from the Parent UnitOfWork -
hasNewObjectsInParentOriginalToClone
protected boolean hasNewObjectsInParentOriginalToClone() -
hasPrivateOwnedObjects
public boolean hasPrivateOwnedObjects()INTERNAL: Return true if privateOwnedObjects is not null and not empty, false otherwise. -
hasOptimisticReadLockObjects
public boolean hasOptimisticReadLockObjects()INTERNAL: Return if there are any optimistic read locks. -
getNewObjectsOriginalToClone
INTERNAL: The new objects stores any objects newly created during the unit of work. On commit they will all be inserted into the database. -
getSequencing
INTERNAL: Return the Sequencing object used by the session.- Overrides:
getSequencing
in classAbstractSession
-
getServerPlatform
INTERNAL: Marked internal as this is not customer API but helper methods for accessing the server platform from within EclipseLink's other sessions types (i.e. not DatabaseSession)- Specified by:
getServerPlatform
in interfaceSession
- Overrides:
getServerPlatform
in classAbstractSession
-
getSessionTypeString
INTERNAL: Returns the type of session, its class.Override to hide from the user when they are using an internal subclass of a known class.
A user does not need to know that their UnitOfWork is a non-deferred UnitOfWork, or that their ClientSession is an IsolatedClientSession.
- Overrides:
getSessionTypeString
in classAbstractSession
-
afterExternalTransactionRollback
public void afterExternalTransactionRollback()INTERNAL: Called after external transaction rolled back. -
releaseJTSConnection
public void releaseJTSConnection()INTERNAL: Called in the end of beforeCompletion of external transaction synchronization listener. Close the managed sql connection corresponding to the external transaction.- Overrides:
releaseJTSConnection
in classAbstractSession
-
getObjectFromNewObjects
INTERNAL: Return any new object matching the expression. Used for in-memory querying. -
getObjectFromNewObjects
public Object getObjectFromNewObjects(Expression selectionCriteria, Class<?> theClass, AbstractRecord translationRow, int valueHolderPolicy) INTERNAL: Return any new object matching the expression. Used for in-memory querying. -
getObjectsDeletedDuringCommit
INTERNAL: Returns all the objects which are deleted during root commit of unit of work. -
hasObjectsDeletedDuringCommit
protected boolean hasObjectsDeletedDuringCommit() -
getOptimisticReadLockObjects
INTERNAL: Return optimistic read lock objects -
getOriginalVersionOfNewObject
INTERNAL: Return the original version of the new object (working clone). -
getOriginalVersionOfObject
ADVANCED: Return the original version of the object(clone) from the parent's identity map.- Specified by:
getOriginalVersionOfObject
in interfaceUnitOfWork
-
getOriginalVersionOfObjectOrNull
public Object getOriginalVersionOfObjectOrNull(Object workingClone, ObjectChangeSet changeSet, ClassDescriptor descriptor, AbstractSession targetSession) INTERNAL: Return the original version of the object(clone) from the parent's identity map. PERF: Use the change set to avoid cache lookups. -
getOriginalVersionOfObjectOrNull
INTERNAL: Return the original version of the object(clone) from the parent's identity map. -
getParent
PUBLIC: Return the parent. This is a unit of work if nested, otherwise a database session or client session.- Specified by:
getParent
in interfaceUnitOfWork
- Overrides:
getParent
in classAbstractSession
-
getProperty
INTERNAL: Search for and return the user defined property from this UOW, if it not found then search for the property from parent.- Specified by:
getProperty
in interfaceSession
- Overrides:
getProperty
in classAbstractSession
-
getPlatform
INTERNAL: Return the platform for a particular class.- Overrides:
getPlatform
in classAbstractSession
-
getShouldThrowConformExceptions
public int getShouldThrowConformExceptions()INTERNAL: Return whether to throw exceptions on conforming queries -
getQuery
PUBLIC: Return the query from the session pre-defined queries with the given name. This allows for common queries to be pre-defined, reused and executed by name.- Overrides:
getQuery
in classAbstractSession
- See Also:
-
getQuery
PUBLIC: Return the query from the session pre-defined queries with the given name. This allows for common queries to be pre-defined, reused and executed by name.- Specified by:
getQuery
in interfaceSession
- Overrides:
getQuery
in classAbstractSession
-
getReadOnlyClasses
ADVANCED: Returns the set of read-only classes in this UnitOfWork.- Specified by:
getReadOnlyClasses
in interfaceUnitOfWork
-
getRemovedObjects
INTERNAL: The removed objects stores any newly registered objects removed during the nested unit of work. On commit they will all be removed from the parent unit of work. -
hasRemovedObjects
protected boolean hasRemovedObjects() -
hasModifyAllQueries
protected boolean hasModifyAllQueries() -
hasDeferredModifyAllQueries
protected boolean hasDeferredModifyAllQueries() -
getState
public int getState()INTERNAL: Find out what the lifecycle state of this UoW is in. -
getTransaction
INTERNAL: PERF: Return the associated external transaction. Used to optimize activeUnitOfWork lookup. -
setTransaction
INTERNAL: PERF: Set the associated external transaction. Used to optimize activeUnitOfWork lookup. -
getUnitOfWorkChangeSet
ADVANCED: Returns the currentChangeSet from the UnitOfWork. This is only valid after the UnitOfWOrk has committed successfully- Specified by:
getUnitOfWorkChangeSet
in interfaceUnitOfWork
-
getUnregisteredExistingObjects
INTERNAL: Used to lazy Initialize the unregistered existing Objects collection.- Returns:
- Map
-
getUnregisteredNewObjects
INTERNAL: This is used to store unregistered objects discovered in the parent so that the child unit of work knows not to register them on commit. -
getUnregisteredNewObjectsInParent
INTERNAL: This is used to store unregistered objects discovered in the parent so that the child unit of work knows not to register them on commit. -
getValidationLevel
public int getValidationLevel()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
getValidationLevel
in interfaceUnitOfWork
-
hasChanges
public boolean hasChanges()ADVANCED: The Unit of work is capable of preprocessing to determine if any on the clone have been changed. This is computationally expensive and should be avoided on large object graphs.- Specified by:
hasChanges
in interfaceUnitOfWork
-
hasModifications
protected boolean hasModifications()INTERNAL: Does this unit of work have any changes or anything that requires a write to the database and a transaction to be started. Should be called after changes are calculated internally by commit.Note if a transaction was begun prematurely it still needs to be committed.
-
initializeIdentityMapAccessor
public void initializeIdentityMapAccessor()INTERNAL: Set up the IdentityMapManager. This method allows subclasses of Session to override the default IdentityMapManager functionality.- Overrides:
initializeIdentityMapAccessor
in classAbstractSession
-
internalExecuteQuery
public Object internalExecuteQuery(DatabaseQuery query, AbstractRecord databaseRow) throws DatabaseException, QueryException INTERNAL: Return the results from executing the database query. the arguments should be a database row with raw data values.- Overrides:
internalExecuteQuery
in classAbstractSession
- Throws:
DatabaseException
QueryException
-
internalRegisterObject
public Object internalRegisterObject(Object object, ClassDescriptor descriptor, boolean isShallowClone) INTERNAL: Register the object with the unit of work. This does not perform wrapping or unwrapping. This is used for internal registration in the merge manager. -
isActive
public boolean isActive()PUBLIC: Return if the unit of work is active. (i.e. has not been released).- Specified by:
isActive
in interfaceUnitOfWork
-
isClassReadOnly
INTERNAL: Checks to see if the specified class or descriptor is read-only or not in this UnitOfWork.- Overrides:
isClassReadOnly
in classAbstractSession
- Returns:
- boolean, true if the class is read-only, false otherwise.
-
isCloneNewObjectFromParent
INTERNAL: Check if the object is already registered in a parent Unit Of Work -
isCloneNewObject
INTERNAL: Check if the object is already registered. -
isCommitPending
public boolean isCommitPending()INTERNAL: Return if the unit of work is waiting to be committed or in the process of being committed. -
isDead
public boolean isDead()INTERNAL: Return if the unit of work is dead. -
isInTransaction
public boolean isInTransaction()PUBLIC: Return whether the session currently has a database transaction in progress.- Overrides:
isInTransaction
in classAbstractSession
-
isMergePending
public boolean isMergePending()INTERNAL: Return if the unit of work is waiting to be merged or in the process of being merged. -
isAfterWriteChangesButBeforeCommit
public boolean isAfterWriteChangesButBeforeCommit()INTERNAL: Has writeChanges() been attempted on this UnitOfWork? It may have either succeeded or failed but either way the UnitOfWork is in a highly restricted state. -
isAfterWriteChangesFailed
protected boolean isAfterWriteChangesFailed()INTERNAL: Once writeChanges has failed all a user can do really is rollback. -
isNestedUnitOfWork
public boolean isNestedUnitOfWork()PUBLIC: Return whether this session is a nested unit of work or not.- Specified by:
isNestedUnitOfWork
in interfaceUnitOfWork
-
isNewObjectInParent
INTERNAL: This method determines if the specified clone is new in the parent UnitOfWork -
isObjectDeleted
INTERNAL: Return if the object has been deleted in this unit of work. -
isObjectNew
INTERNAL: This method is used to determine if the clone is a new Object in the UnitOfWork -
isUnregisteredExistingObject
INTERNAL: Return if the object is a known unregistered existing object. -
isObjectRegistered
ADVANCED: Return whether the clone object is already registered.- Specified by:
isObjectRegistered
in interfaceUnitOfWork
-
isOriginalNewObject
INTERNAL: Return whether the original object is new. It was either registered as new or discovered as a new aggregate within another new object. -
isSmartMerge
public static boolean isSmartMerge()INTERNAL: Return the status of smart merge -
issueSQLbeforeCompletion
public void issueSQLbeforeCompletion()INTERNAL: For synchronized units of work, dump SQL to database. For cases where writes occur before the end of the transaction don't commit -
issueSQLbeforeCompletion
public void issueSQLbeforeCompletion(boolean commitTransaction) INTERNAL: For synchronized units of work, dump SQL to database. For cases where writes occur before the end of the transaction don't commit -
issueModifyAllQueryList
protected void issueModifyAllQueryList()INTERNAL: Will notify all the deferred ModifyAllQuery's (excluding UpdateAllQuery's) and deferred UpdateAllQuery's to execute. -
isUnitOfWork
public boolean isUnitOfWork()PUBLIC: Return if this session is a unit of work.- Specified by:
isUnitOfWork
in interfaceSession
- Overrides:
isUnitOfWork
in classAbstractSession
-
isUnregisteredNewObjectInParent
INTERNAL: Return if the object was existing but not registered in the parent of the nested unit of work. -
mergeBmpAndWsEntities
protected void mergeBmpAndWsEntities()INTERNAL: BMP and Websphere CMP entities have to be merged if they are registered in the unit of work. Check to see if there are any such entities and do the merge if required. -
mergeChangesIntoParent
protected void mergeChangesIntoParent()INTERNAL: Merge the changes to all objects to the parent. -
mergeClone
PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged.- Specified by:
mergeClone
in interfaceUnitOfWork
- Returns:
- the registered version for the clone being merged.
- See Also:
-
mergeClone
INTERNAL: Merge the attributes of the clone into the unit of work copy. -
mergeClonesAfterCompletion
public void mergeClonesAfterCompletion()INTERNAL: for synchronized units of work, merge changes into parent -
mergeCloneWithReferences
PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged. This will include references from dependent objects to independent objects.- Specified by:
mergeCloneWithReferences
in interfaceUnitOfWork
- Returns:
- the registered version for the clone being merged.
- See Also:
-
mergeCloneWithReferences
PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged. This will include references from dependent objects to independent objects.- Returns:
- the registered version for the clone being merged.
- See Also:
-
mergeCloneWithReferences
INTERNAL: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged. This will include references from dependent objects to independent objects.- Returns:
- the registered version for the clone being merged.
- See Also:
-
mergeCloneWithReferences
INTERNAL: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged. This will include references from dependent objects to independent objects.- Returns:
- the registered version for the clone being merged.
- See Also:
-
newInstance
PUBLIC: Return a new instance of the class registered in this unit of work. This can be used to ensure that new objects are registered correctly.- Specified by:
newInstance
in interfaceUnitOfWork
-
performRemove
INTERNAL: This method will perform a delete operation on the provided objects pre-determining the objects that will be deleted by a commit of the UnitOfWork including privately owned objects. It does not execute a query for the deletion of these objects as the normal deleteobject operation does. Mainly implemented to provide EJB 3.0 deleteObject support. -
performRemovePrivateOwnedObjectFromChangeSet
INTERNAL: Cascade remove the private owned object from the owned UnitOfWorkChangeSet -
performFullValidation
public void performFullValidation()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
performFullValidation
in interfaceUnitOfWork
-
performPartialValidation
public void performPartialValidation()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
performPartialValidation
in interfaceUnitOfWork
-
populateAndRegisterObject
protected void populateAndRegisterObject(Object original, Object workingClone, CacheKey unitOfWorkCacheKey, CacheKey parentCacheKey, ClassDescriptor descriptor) INTERNAL: This method is called from clone and register. It includes the processing required to clone an object, including populating attributes, putting in UOW identitymap and building a backupclone -
postMergeChanges
INTERNAL: Remove objects from parent's identity map. -
preMergeChanges
protected void preMergeChanges()INTERNAL: Remove objects deleted during commit from clone and new object cache so that these are not merged -
printRegisteredObjects
public void printRegisteredObjects()PUBLIC: Print the objects in the unit of work. The output of this method will be logged to this unit of work's SessionLog at SEVERE level.- Specified by:
printRegisteredObjects
in interfaceUnitOfWork
-
processDeleteObjectQuery
INTERNAL: This method is used to process delete queries that pass through the unitOfWork It is extracted out of the internalExecuteQuery method to reduce duplication -
basicPrintRegisteredObjects
protected void basicPrintRegisteredObjects()INTERNAL: Print the objects in the unit of work. -
registerAllObjects
PUBLIC: Register the objects with the unit of work. All newly created root domain objects must be registered to be inserted on commit. Also any existing objects that will be edited and were not read from this unit of work must also be registered. Once registered any changes to the objects will be committed to the database on commit.- Specified by:
registerAllObjects
in interfaceUnitOfWork
- Returns:
- is the clones of the original objects, the return value must be used for editing. Editing the original is not allowed in the unit of work.
-
registerAllObjects
public Vector registerAllObjects(Vector domainObjects) throws DatabaseException, OptimisticLockException PUBLIC: Register the objects with the unit of work. All newly created root domain objects must be registered to be inserted on commit. Also any existing objects that will be edited and were not read from this unit of work must also be registered. Once registered any changes to the objects will be committed to the database on commit.- Returns:
- is the clones of the original objects, the return value must be used for editing. Editing the original is not allowed in the unit of work.
- Throws:
DatabaseException
OptimisticLockException
-
registerExistingObject
ADVANCED: Register the existing object with the unit of work. This is a advanced API that can be used if the application can guarantee the object exists on the database. When registerObject is called the unit of work determines existence through the descriptor's doesExist setting.- Specified by:
registerExistingObject
in interfaceUnitOfWork
- Returns:
- The clone of the original object, the return value must be used for editing. Editing the original is not allowed in the unit of work.
-
registerExistingObject
ADVANCED: Register the existing object with the unit of work. This is a advanced API that can be used if the application can guarantee the object exists on the database. When registerObject is called the unit of work determines existence through the descriptor's doesExist setting.- Returns:
- The clone of the original object, the return value must be used for editing. Editing the original is not allowed in the unit of work.
-
registerExistingObject
public Object registerExistingObject(Object objectToRegister, ClassDescriptor descriptor, Object queryPrimaryKey, boolean isFromSharedCache) INTERNAL: Register the existing object with the unit of work. This is a advanced API that can be used if the application can guarantee the object exists on the database. When registerObject is called the unit of work determines existence through the descriptor's doesExist setting.- Returns:
- The clone of the original object, the return value must be used for editing. Editing the original is not allowed in the unit of work.
-
registerNewContainerBean
INTERNAL: Register the new container bean with the unit of work. Normally the registerObject method should be used for all registration of new and existing objects. This version of the register method can only be used for new container beans.- See Also:
-
registerNewContainerBeanForCMP
INTERNAL: Register the new Bean with the unit of work. This will register the new Bean with cloning. Normally the registerObject method should be used for all registration of new and existing objects. This version of the register method can only be used for new objects. -
registerNewObject
ADVANCED: Register the new object with the unit of work. This will register the new object without cloning. Normally the registerObject method should be used for all registration of new and existing objects. This version of the register method can only be used for new objects. This method should only be used if a new object is desired to be registered without cloning.- Specified by:
registerNewObject
in interfaceUnitOfWork
- See Also:
-
registerNewObject
INTERNAL: Updated to allow passing in of the object's descriptor Register the new object with the unit of work. This will register the new object without cloning. Normally the registerObject method should be used for all registration of new and existing objects. This version of the register method can only be used for new objects. This method should only be used if a new object is desired to be registered without cloning.- See Also:
-
discoverAndPersistUnregisteredNewObjects
public void discoverAndPersistUnregisteredNewObjects(Object object, boolean cascadePersist, Map newObjects, Map unregisteredExistingObjects, Map visitedObjects, Set cascadeErrors) INTERNAL: Discover any new objects referenced from registered objects and persist them. This is similar to persist, except that it traverses (all changed or new) objects during the commit to find any unregistered new objects and persists them. Only objects referenced by cascade persist mappings will be persisted, an error will be thrown from non-cascade persist mappings to new objects (detached existing object are ok...in thoery). This is specific to EJB 3.0 support.- Parameters:
cascadePersist
- determines if this call is cascading from a cascadePersist mapping or not.newObjects
- any new objects found must be added to this collection.
-
registerNewObjectForPersist
INTERNAL: Register the new object with the unit of work. This will register the new object without cloning. Checks based on existence will be completed and the create will be cascaded based on the object's mappings cascade requirements. This is specific to EJB 3.0 support.- See Also:
-
wasDeleted
INTERNAL: Return if the object was deleted previously (in a flush). -
registerNotRegisteredNewObjectForPersist
protected void registerNotRegisteredNewObjectForPersist(Object newObject, ClassDescriptor descriptor) INTERNAL: Called only by registerNewObjectForPersist method, and only if newObject is not already registered. Could be overridden in subclasses. -
registerNewObjectClone
INTERNAL: Register the working copy of a new object and its original. The user must edit the working copy and the original is used to merge into the parent. This mapping is kept both ways because lookup is required in both directions. -
registerNewObjectInIdentityMap
protected void registerNewObjectInIdentityMap(Object clone, Object original, ClassDescriptor descriptor) INTERNAL: Add the new object to the cache if set to. This is useful for using mergeclone on new objects. -
registerObject
PUBLIC: Register the object with the unit of work. All newly created root domain objects must be registered to be inserted on commit. Also any existing objects that will be edited and were not read from this unit of work must also be registered. Once registered any changes to the objects will be committed to the database on commit.- Specified by:
registerObject
in interfaceUnitOfWork
- Returns:
- the clone of the original object, the return value must be used for editing, ** Editing the original is not allowed in the unit of work. **
-
registerObject
INTERNAL: Allows for calling method to provide the descriptor information for this object. Prevents double lookup of descriptor. Register the object with the unit of work. All newly created root domain objects must be registered to be inserted on commit. Also any existing objects that will be edited and were not read from this unit of work must also be registered. Once registered any changes to the objects will be committed to the database on commit. calling this method will also sort the objects into different different groups depending on if the object being registered is a bean or a regular Java object and if its updates are deferred, non-deferred or if all modifications are deferred.- Returns:
- the clone of the original object, the return value must be used for editing,
-
registerOriginalNewObjectFromNestedUnitOfWork
public void registerOriginalNewObjectFromNestedUnitOfWork(Object originalObject, Object backupClone, Object newInstance, ClassDescriptor descriptor) INTERNAL: Register a new object from a nested unit of work into its parent. -
registerWithTransactionIfRequired
public void registerWithTransactionIfRequired()INTERNAL: Register this UnitOfWork against an external transaction controller -
release
public void release()PUBLIC: Release the unit of work. This terminates this unit of work. Because the unit of work operates on its own object space (clones) no work is required. The unit of work should no longer be used or referenced by the application beyond this point so that it can be garbage collected.- Specified by:
release
in interfaceSession
- Specified by:
release
in interfaceUnitOfWork
- Overrides:
release
in classAbstractSession
- See Also:
-
removeAllReadOnlyClasses
PUBLIC: Empties the set of read-only classes. It is illegal to call this method on nested UnitOfWork objects. A nested UnitOfWork cannot have a subset of its parent's set of read-only classes. Also removes classes which are read only because their descriptors are readonly- Specified by:
removeAllReadOnlyClasses
in interfaceUnitOfWork
- Throws:
ValidationException
-
removeForceUpdateToVersionField
ADVANCED: Remove optimistic read lock from the object See forceUpdateToVersionField(Object)- Specified by:
removeForceUpdateToVersionField
in interfaceUnitOfWork
-
removePrivateOwnedObject
INTERNAL: Remove a privately owned object from the privateOwnedObjects Map. The UnitOfWork needs to keep track of privately owned objects in order to detect and remove private owned objects which are de-referenced. When an object (which is referenced) is removed from the privateOwnedObjects Map, it is no longer considered for removal from ChangeSets and the UnitOfWork identitymap. -
removeReadOnlyClass
PUBLIC: Removes a Class from the receiver's set of read-only classes. It is illegal to try to send this method to a nested UnitOfWork.- Specified by:
removeReadOnlyClass
in interfaceUnitOfWork
- Throws:
ValidationException
-
revertAndResume
public void revertAndResume()PUBLIC: Revert all changes made to any registered object. Clear all deleted and new objects. Revert should not be confused with release which it the normal compliment to commit. Revert is more similar to commit and resume, however reverts all changes and resumes. If you do not require to resume the unit of work release should be used instead.- Specified by:
revertAndResume
in interfaceUnitOfWork
- See Also:
-
revertObject
PUBLIC: Revert the object's attributes from the parent. This also reverts the object privately-owned parts.- Specified by:
revertObject
in interfaceUnitOfWork
- Returns:
- the object reverted.
- See Also:
-
revertObject
INTERNAL: Revert the object's attributes from the parent. This uses merging to merge the object changes. -
rollbackTransaction
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow. The uow shares its parents transactions.- Overrides:
rollbackTransaction
in classAbstractSession
- Throws:
DatabaseException
- if the database connection is lost or the rollback fails.
-
rollbackTransaction
INTERNAL: rollbackTransaction() with a twist for external transactions.writeChanges() is called outside the JTA beforeCompletion(), so the accompanying exception won't propagate up and cause a rollback by itself.
Instead must mark the transaction for rollback only here.
If internally started external transaction or no external transaction can still rollback normally.
- Parameters:
intendedToCommitTransaction
- whether we were inside a commit or just trying to write out changes early.- Throws:
DatabaseException
-
scanForConformingInstances
public Map<Object,Object> scanForConformingInstances(Expression selectionCriteria, Class<?> referenceClass, AbstractRecord arguments, ObjectLevelReadQuery query) INTERNAL: Scans the UnitOfWork identity map for conforming instances.Later this method can be made recursive to check all parent units of work also.
- Parameters:
selectionCriteria
- must be cloned and specially prepared for conforming- Returns:
- Map to facilitate merging with conforming instances returned from a query on the database.
-
setAllClonesCollection
INTERNAL: Used to set the collections of all objects in the UnitOfWork. -
setCloneMapping
INTERNAL: Set the clone mapping. The clone mapping contains clone of all registered objects, this is required to store the original state of the objects when registered so that only what is changed will be committed to the database and the parent, (this is required to support parallel unit of work). -
setContainerBeans
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context. -
setContainerUnitOfWork
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context. -
setDead
public void setDead()INTERNAL: set UoW lifecycle state variable to DEATH -
setDeletedObjects
INTERNAL: The deleted objects stores any objects removed during the unit of work. On commit they will all be removed from the database. -
setLifecycle
protected void setLifecycle(int lifecycle) INTERNAL: The life cycle tracks if the unit of work is active and is used for JTS. -
setMergeManager
INTERNAL: A reference to the last used merge manager. This is used to track locked objects. -
setNewObjectsCloneToOriginal
INTERNAL: The new objects stores any objects newly created during the unit of work. On commit they will all be inserted into the database. -
setupPrimaryKeyToNewObjects
protected void setupPrimaryKeyToNewObjects()INTERNAL: Create the map of primary key to new objects used to speed up in-memory querying. -
addNewObjectToPrimaryKeyToNewObjects
INTERNAL: Extracts the primary key from a new object and puts it in primaryKeyToNewObjects. -
addNewObjectToPrimaryKeyToNewObjects
INTERNAL: Extracts the primary key from a new object and puts it in primaryKeyToNewObjects. Allows passing of the ClassDescriptor. -
removeObjectFromPrimaryKeyToNewObjects
INTERNAL: Extracts the primary key and removes an object from primaryKeyToNewObjects. -
removeObjectFromPrimaryKeyToNewObjects
INTERNAL: Removes an object from primaryKeyToNewObjects. -
setNewObjectsOriginalToClone
INTERNAL: The new objects stores any objects newly created during the unit of work. On commit they will all be inserted into the database. -
setObjectsDeletedDuringCommit
INTERNAL: Set the objects that have been deleted. -
setParent
INTERNAL: Set the parent. This is a unit of work if nested, otherwise a database session or client session. -
setPendingMerge
public void setPendingMerge()INTERNAL: set UoW lifecycle state variable to PENDING_MERGE -
setPreDeleteComplete
public void setPreDeleteComplete(boolean preDeleteComplete) - Parameters:
preDeleteComplete
- the preDeleteComplete to set
-
setReadOnlyClasses
INTERNAL: Gives a new set of read-only classes to the receiver. This set of classes given are checked that subclasses of a read-only class are also in the read-only set provided. -
setRemovedObjects
INTERNAL: The removed objects stores any newly registered objects removed during the nested unit of work. On commit they will all be removed from the parent unit of work. -
setResumeUnitOfWorkOnTransactionCompletion
public void setResumeUnitOfWorkOnTransactionCompletion(boolean resumeUnitOfWork) INTERNAL: Set if this UnitofWork should be resumed after the end of the transaction Used when UnitOfWork is synchronized with external transaction control -
shouldDiscoverNewObjects
public boolean shouldDiscoverNewObjects()INTERNAL: Set if this UnitofWork should discover new objects on commit. -
setShouldDiscoverNewObjects
public void setShouldDiscoverNewObjects(boolean shouldDiscoverNewObjects) INTERNAL: Set if this UnitofWork should discover new objects on commit. -
setShouldCascadeCloneToJoinedRelationship
public void setShouldCascadeCloneToJoinedRelationship(boolean shouldCascadeCloneToJoinedRelationship) INTERNAL: True if the value holder for the joined attribute should be triggered. Required by ejb30 fetch join. -
shouldForceReadFromDB
INTERNAL: Calculate whether we should read directly from the database to the UOW. This may be necessary in subclasses of UnitOfWork that have special behavior- See Also:
-
setShouldNewObjectsBeCached
public void setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached) ADVANCED: By default new objects are not cached until the exist on the database. Occasionally if mergeClone is used on new objects and is required to allow multiple merges on the same new object, then if the new objects are not cached, each mergeClone will be interpretted as a different new object. By setting new objects to be cached mergeClone can be performed multiple times before commit. New objects cannot be cached unless they have a valid assigned primary key before being registered. New object with non-null invalid primary keys such as 0 or '' can cause problems and should not be used with this option.- Specified by:
setShouldNewObjectsBeCached
in interfaceUnitOfWork
-
setShouldPerformDeletesFirst
public void setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst) ADVANCED: By default deletes are performed last in a unit of work. Sometimes you may want to have the deletes performed before other actions.- Specified by:
setShouldPerformDeletesFirst
in interfaceUnitOfWork
-
setShouldThrowConformExceptions
public void setShouldThrowConformExceptions(int shouldThrowExceptions) ADVANCED: Conforming queries can be set to provide different levels of detail about the exceptions they encounter There are two levels: DO_NOT_THROW_CONFORM_EXCEPTIONS = 0; THROW_ALL_CONFORM_EXCEPTIONS = 1;- Specified by:
setShouldThrowConformExceptions
in interfaceUnitOfWork
-
setSmartMerge
public static void setSmartMerge(boolean option) INTERNAL: Set smart merge flag. This feature is used in WL to merge dependent values without SessionAccessor -
setSynchronized
public void setSynchronized(boolean synched) INTERNAL: Set isSynchronized flag to indicate that this session is a synchronized unit of work.- Overrides:
setSynchronized
in classAbstractSession
-
setUnitOfWorkChangeSet
INTERNAL: Sets the current UnitOfWork change set to be the one passed in. -
setUnregisteredExistingObjects
INTERNAL: Used to set the unregistered existing objects vector used when validation has been turned off.- Parameters:
newUnregisteredExistingObjects
- Map
-
setUnregisteredNewObjects
INTERNAL: -
setUnregisteredNewObjectsInParent
INTERNAL: -
setValidationLevel
public void setValidationLevel(int validationLevel) ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
setValidationLevel
in interfaceUnitOfWork
-
setWasTransactionBegunPrematurely
public void setWasTransactionBegunPrematurely(boolean wasTransactionBegunPrematurely) INTERNAL: Set a flag in the root UOW to indicate that a pess. locking or non-selecting SQL query was executed and forced a transaction to be started. -
shallowMergeClone
PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or other serialization mechanisms), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. Only direct attributes are merged.- Specified by:
shallowMergeClone
in interfaceUnitOfWork
- Returns:
- the registered version for the clone being merged.
- See Also:
-
shallowRevertObject
PUBLIC: Revert the object's attributes from the parent. This only reverts the object's direct attributes.- Specified by:
shallowRevertObject
in interfaceUnitOfWork
- Returns:
- the object reverted.
- See Also:
-
shallowUnregisterObject
ADVANCED: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. The method will only unregister the clone, none of its parts.- Specified by:
shallowUnregisterObject
in interfaceUnitOfWork
-
shouldCascadeCloneToJoinedRelationship
public boolean shouldCascadeCloneToJoinedRelationship()INTERNAL: True if the value holder for the joined attribute should be triggered. Required by ejb30 fetch join. -
shouldNewObjectsBeCached
public boolean shouldNewObjectsBeCached()ADVANCED: By default new objects are not cached until the exist on the database. Occasionally if mergeClone is used on new objects and is required to allow multiple merges on the same new object, then if the new objects are not cached, each mergeClone will be interpretted as a different new object. By setting new objects to be cached mergeClone can be performed multiple times before commit. New objects cannot be cached unless they have a valid assigned primary key before being registered. New object with non-null invalid primary keys such as 0 or '' can cause problems and should not be used with this option.- Specified by:
shouldNewObjectsBeCached
in interfaceUnitOfWork
-
shouldValidateExistence
public boolean shouldValidateExistence()Return the default to determine if does-exist should be performed on persist. -
setShouldValidateExistence
public void setShouldValidateExistence(boolean shouldValidateExistence) Set the default to determine if does-exist should be performed on persist. -
shouldPerformDeletesFirst
public boolean shouldPerformDeletesFirst()ADVANCED: By default all objects are inserted and updated in the database before any object is deleted. If this flag is set to true, deletes will be performed before inserts and updates- Specified by:
shouldPerformDeletesFirst
in interfaceUnitOfWork
-
shouldPerformFullValidation
public boolean shouldPerformFullValidation()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not refered in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
shouldPerformFullValidation
in interfaceUnitOfWork
-
shouldPerformNoValidation
public boolean shouldPerformNoValidation()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not refered in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violated in the unit of work.- Specified by:
shouldPerformNoValidation
in interfaceUnitOfWork
-
shouldPerformPartialValidation
public boolean shouldPerformPartialValidation()ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not refered after commit, ensures that objects from the parent cache are not refered in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.- Specified by:
shouldPerformPartialValidation
in interfaceUnitOfWork
-
shouldResumeUnitOfWorkOnTransactionCompletion
public boolean shouldResumeUnitOfWorkOnTransactionCompletion()INTERNAL: Returns true if this UnitofWork should be resumed after the end of the transaction Used when UnitOfWork is synchronized with external transaction control -
shouldStoreBypassCache
public boolean shouldStoreBypassCache()INTERNAL: This is a JPA setting that is off by default in regular EclipseLink. It's used to avoid updating the shared cache when the cacheStoreMode property is set to BYPASS.- See Also:
-
storeModifyAllQuery
INTERNAL: Store the ModifyAllQuery's from the UoW in the list. They are always deferred to commit time -
storeDeferredModifyAllQuery
INTERNAL: Store the deferred UpdateAllQuery's from the UoW in the list for execution. -
synchronizeAndResume
public void synchronizeAndResume()INTERNAL Synchronize the clones and update their backup copies. Called after commit and commit and resume. -
resumeUnitOfWork
public void resumeUnitOfWork()INTERNAL: Resume the unit of work state after a flush, or resume operation. This will occur on commitAndResume, JPA commit and JPA flush. -
undeleteObject
INTERNAL: This method is used to transition an object from the deleted objects list to be simply be register. -
unregisterObject
PUBLIC: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. The method will only unregister the object and its privately owned parts- Specified by:
unregisterObject
in interfaceUnitOfWork
-
unregisterObject
INTERNAL: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. -
unregisterObject
INTERNAL: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. -
updateChangeTrackersIfRequired
public void updateChangeTrackersIfRequired(Object objectToWrite, ObjectChangeSet changeSetToWrite, UnitOfWorkImpl uow, ClassDescriptor descriptor) INTERNAL: This method is used internally to update the tracked objects if required -
updateDerivedIds
INTERNAL: On persist and flush operations we must update any derived id fields. -
validateObjectSpace
public void validateObjectSpace()ADVANCED: This can be used to help debugging an object-space corruption. An object-space corruption is when your application has incorrectly related a clone to an original object. This method will validate that all registered objects are in a correct state and throw an error if not, it will contain the full stack of object references in the error message. If you call this method after each register or change you perform it will pin-point where the error was made.- Specified by:
validateObjectSpace
in interfaceUnitOfWork
-
wasTransactionBegunPrematurely
public boolean wasTransactionBegunPrematurely()INTERNAL: Indicates if a transaction was begun by a pessimistic locking or non-selecting query. Traverse to the root UOW to get value. -
retryQuery
public Object retryQuery(DatabaseQuery query, AbstractRecord row, DatabaseException databaseException, int retryCount, AbstractSession executionSession) INTERNAL: A query execution failed due to an invalid query. Re-connect and retry the query.- Overrides:
retryQuery
in classAbstractSession
-
writeChanges
public void writeChanges()ADVANCED: Writes all changes now before commit(). The commit process will begin and all changes will be written out to the datastore, but the datastore transaction will not be committed, nor will changes be merged into the global cache.A subsequent commit (on UnitOfWork or global transaction) will be required to finalize the commit process.
As the commit process has begun any attempt to register objects, or execute object-level queries will generate an exception. Report queries, non-caching queries, and data read/modify queries are allowed.
On exception any global transaction will be rolled back or marked rollback only. No recovery of this UnitOfWork will be possible.
Can only be called once. It can not be used to write out changes in an incremental fashion.
Use to partially commit a transaction outside of a JTA transaction's callbacks. Allows you to get back any exception directly.
Use to commit a UnitOfWork in two stages.
- Specified by:
writeChanges
in interfaceUnitOfWork
-
writesCompleted
public void writesCompleted()INTERNAL: This method notifies the accessor that a particular sets of writes has completed. This notification can be used for such thing as flushing the batch mechanism- Overrides:
writesCompleted
in classAbstractSession
-
getBatchQueries
INTERNAL: When in transaction batch read objects must use query local to the unit of work. -
setBatchQueries
INTERNAL: When in transaction batch read objects must use query local to the unit of work. -
getPessimisticLockedObjects
INTERNAL: -
addToChangeTrackedHardList
-
addPessimisticLockedClone
INTERNAL: -
addPrivateOwnedObject
INTERNAL: Add a privately owned object to the privateOwnedObjectsMap. The UnitOfWork needs to keep track of privately owned objects in order to detect and remove private owned objects which are de-referenced. -
isPessimisticLocked
INTERNAL: Return if the clone has been pessimistic locked in this unit of work. -
hasPessimisticLockedObjects
public boolean hasPessimisticLockedObjects()INTERNAL: Return true if there are any pessimistic locked objects in this unit of work, false otherwise. -
isPreDeleteComplete
public boolean isPreDeleteComplete()- Returns:
- the preDeleteComplete
-
setWasNonObjectLevelModifyQueryExecuted
public void setWasNonObjectLevelModifyQueryExecuted(boolean wasNonObjectLevelModifyQueryExecuted) INTERNAL: True if either DataModifyQuery or ModifyAllQuery was executed. In absense of transaction the query execution starts one, therefore the flag may only be true in transaction, it's reset on commit or rollback. -
wasNonObjectLevelModifyQueryExecuted
public boolean wasNonObjectLevelModifyQueryExecuted()INTERNAL: True if either DataModifyQuery or ModifyAllQuery was executed. -
shouldReadFromDB
public boolean shouldReadFromDB()INTERNAL: Indicates whether readObject should return the object read from the db in case there is no object in uow cache (as opposed to fetching the object from parent's cache). Note that wasNonObjectLevelModifyQueryExecuted()==true implies inTransaction()==true. -
releaseReadConnection
INTERNAL: Release the read connection to the read connection pool.- Overrides:
releaseReadConnection
in classAbstractSession
-
clear
public void clear(boolean shouldClearCache) INTERNAL: This method will clear all registered objects from this UnitOfWork. If parameter value is 'true' then the cache(s) are cleared, too. -
clearForClose
public void clearForClose(boolean shouldClearCache) INTERNAL: Call this method if the uow will no longer be used for committing transactions: all the change sets will be dereferenced, and (optionally) the cache cleared. If the uow is not released, but rather kept around for ValueHolders, then identity maps shouldn't be cleared: the parameter value should be 'false'. The lifecycle set to Birth so that uow ValueHolder still could be used. Alternatively, if called from release method then everything should go and therefore parameter value should be 'true'. In this case lifecycle won't change - uow.release (optionally) calls this method when it (uow) is already dead. The reason for calling this method from release is to free maximum memory right away: the uow might still be referenced by objects using UOWValueHolders (though they shouldn't be around they still might). We defer a clear() call to release() if the uow lifecycle is 1,2 or 4 (*Pending). -
shouldClearForCloseOnRelease
public boolean shouldClearForCloseOnRelease()INTERNAL: Indicates whether clearForClose method should be called by release method. -
createMap
This method is used internally to create a map to hold the persistenceContexts. A weak map is returned if ReferenceMode is weak. -
createMap
This method is used internally to create a map to hold the persistenceContexts. A weak map is returned if ReferenceMode is weak. -
cloneMap
This method is used internally to clone a map that holds the persistenceContexts. A weak map is returned if ReferenceMode is weak. -
getReferenceMode
-
getChangeTrackedHardList
INTERNAL: Return the list of object with changes. This is used in weak reference mode to avoid garbage collection of changed objects. -
getReference
Get an instance, whose state may be lazily fetched. If the requested instance does not exist in the database, null is returned, or the object will fail when accessed. The instance will be lazy when it does not exist in the cache, and supports fetch groups.- Specified by:
getReference
in interfaceUnitOfWork
- Parameters:
id
- The primary key of the object, either as a List, singleton, IdClass or an instance of the object.
-
verifyMutexThreadIntegrityBeforeRelease
public boolean verifyMutexThreadIntegrityBeforeRelease()INTERNAL: 272022: Avoid releasing locks on the wrong server thread. If the current thread and the active thread on the mutex do not match - switch them Before we release acquired locks (do the same as we do for mergeClonesBeforeCompletion()) Check that the current thread is the active thread on all lock managers by checking the cached lockThread on the mergeManager. If we find that these 2 threads are different - then all threads in the acquired locks list are different. Switch the activeThread on the mutex to this current thread for each lock.- Returns:
- true if threads were switched
-
createCloneQueryValueHolder
public <T> DatabaseValueHolder<T> createCloneQueryValueHolder(ValueHolderInterface<T> attributeValue, Object clone, AbstractRecord row, ForeignReferenceMapping mapping) - Overrides:
createCloneQueryValueHolder
in classAbstractSession
-
createCloneTransformationValueHolder
public <T> DatabaseValueHolder<T> createCloneTransformationValueHolder(ValueHolderInterface<T> attributeValue, Object original, Object clone, AbstractTransformationMapping mapping) - Overrides:
createCloneTransformationValueHolder
in classAbstractSession
-
getDeletionDependencies
INTERNAL: Return deleted objects that have reference to other deleted objects. This is need to delete cycles of objects in the correct order. -
addDeletionDependency
INTERNAL: Record deleted objects that have reference to other deleted objects. This is need to delete cycles of objects in the correct order. -
getDeletionDependencies
INTERNAL: Return references to other deleted objects for this deleted object. This is need to delete cycles of objects in the correct order. -
getCommitOrder
ADVANCED: Return the commit order.- Specified by:
getCommitOrder
in interfaceUnitOfWork
-
setCommitOrder
ADVANCED: Set the commit order.- Specified by:
setCommitOrder
in interfaceUnitOfWork
-