Class UnitOfWorkImpl
- java.lang.Object
-
- org.eclipse.persistence.internal.core.sessions.CoreAbstractSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>
-
- org.eclipse.persistence.internal.sessions.AbstractSession
-
- org.eclipse.persistence.internal.sessions.UnitOfWorkImpl
-
- All Implemented Interfaces:
Serializable
,Cloneable
,CoreSession<ClassDescriptor,Login,Platform,Project,SessionEventManager>
,CommandProcessor
,Session
,UnitOfWork
- Direct Known Subclasses:
RepeatableWriteUnitOfWork
public class UnitOfWorkImpl extends AbstractSession implements UnitOfWork
Implementation of org.eclipse.persistence.sessions.UnitOfWork The public interface should be used.- See Also:
Purpose: To allow object level transactions. Description: The unit of work is a session that implements all of the normal protocol of an EclipseLink session. It can be spawned from any other session including another unit of work. Objects can be brought into the unit of work through reading them or through registering them. The unit of work will operate on its own object space, that is the objects within the unit of work will be clones of the original objects. When the unit of work is committed, all changes to any objects registered within the unit of work will be committed to the database. A minimal commit/update will be performed and any foreign keys/circular reference/referential integrity will be resolved. If the commit to the database is successful the changed objects will be merged back into the unit of work parent session. Responsibilities: Allow parallel transactions against a session's objects. Allow nested transactions. Not require the application to write objects that is changes, automatically determine what has changed. Perform a minimal commit/update of all changes that occurred. Resolve foreign keys for newly created objects and maintain referential integrity. Allow for the object transaction to use its own object space.
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.persistence.sessions.UnitOfWork
UnitOfWork.CommitOrderType
-
-
Field Summary
Fields Modifier and Type Field Description static int
AfterExternalTransactionRolledBack
protected Map<Object,Object>
allClones
This member variable contains a copy of all of the clones for this particular UOWprotected Map<ReadQuery,ReadQuery>
batchQueries
When in transaction batch read objects must use query local to the unit of work.static int
Birth
protected Set<Object>
cascadeDeleteObjects
Set of objects that were deleted by database cascade delete constraints.protected Set<Object>
changeTrackedHardList
protected int
cloneDepth
Used during the cloning process to track the recursive depth in.protected Map<Object,Object>
cloneMapping
Map of all the clones.protected Map<Object,Object>
cloneToOriginals
As well as used as lookup in merge algorithm for aggregates and othersprotected UnitOfWork.CommitOrderType
commitOrder
Allow updates and deletes to be ordered by id or changes to avoid possible deadlocks.static int
CommitPending
static int
CommitTransactionPending
protected Map<Object,Object>
containerBeans
protected UnitOfWorkImpl
containerUnitOfWork
This is only used for EJB entity beans to manage beans accessed in a transaction context.long
CREATION_THREAD_HASHCODE
long
CREATION_THREAD_ID
String
CREATION_THREAD_NAME
static int
Death
protected List<Object[]>
deferredModifyAllQueries
Contains deferred ModifyAllQuery's that have translation row for execution only.protected Map<Object,Object>
deletedObjects
protected Map<DatabaseMapping,List<Object>>
deletedPrivateOwnedObjects
Stores all of the private owned objects that have been removed and may need to cascade deletionprotected Map<Object,Set<Object>>
deletionDependencies
Used to store deleted objects that have reference to other deleted objects.static int
DO_NOT_THROW_CONFORM_EXCEPTIONS
Used for Conforming Queriesstatic int
Full
protected boolean
isNestedUnitOfWork
PERF: Cache isNestedUnitOfWork check.protected MergeManager
lastUsedMergeManager
Used to store the list of locks that this UnitOfWork has acquired for this mergeprotected int
lifecycle
With the new synchronized unit of work, need a lifecycle state variable to track birth, committed, pending_merge and death.static String
LOCK_QUERIES_PROPERTY
protected MergeManager
mergeManagerForActiveMerge
temporarily holds a reference to a merge manager that is calling this UnitOfWork during mergestatic int
MergePending
protected List<ModifyAllQuery>
modifyAllQueries
lazy initialization done in storeModifyAllQuery.protected Map<Object,Object>
newAggregates
protected Map<Object,Object>
newObjectsCloneToMergeOriginal
Stores a map from the clone to the original merged object, as a different instance is used as the original for merges.protected Map<Object,Object>
newObjectsCloneToOriginal
protected Map<Object,Object>
newObjectsInParent
used to store a list of the new objects in the parentprotected Map<Object,Object>
newObjectsInParentOriginalToClone
protected Map<Object,Object>
newObjectsOriginalToClone
static int
None
protected Map<Object,Object>
objectsDeletedDuringCommit
protected Map<Object,Object>
optimisticReadLockObjects
Kept reference of read lock objectsprotected AbstractSession
parent
static int
Partial
protected Map<Object,Object>
pessimisticLockedObjects
use to track pessimistic locked objectsprotected boolean
preDeleteComplete
This attribute records when the preDelete stage of Commit has completedprotected Map<DatabaseMapping,Set>
privateOwnedObjects
Cache references of private owned objects for the removal of private owned orphansstatic String
ReadLockOnly
Used for read lock to determine update the version field with the same value or increment valuestatic String
ReadLockUpdateVersion
protected Set<Class>
readOnlyClasses
Read-only class can be used for reference data to avoid cloning when not required.protected ReferenceMode
referenceMode
This stored the reference mode for this UOW.protected Map<Object,Object>
removedObjects
protected boolean
resumeOnTransactionCompletion
True if UnitOfWork should be resumed on completion of transaction.protected boolean
shouldCascadeCloneToJoinedRelationship
True if the value holder for the joined attribute should be triggered.protected boolean
shouldDiscoverNewObjects
PERF: Allows discover new objects to be skipped if app always calls persist.protected boolean
shouldNewObjectsBeCached
Allow for double merges of new objects by putting them into the cache.protected boolean
shouldPerformDeletesFirst
Flag indicating that deletes should be performed before other updates.protected int
shouldThrowConformExceptions
Flag indicating how to deal with exceptions on conforming queries.protected boolean
shouldValidateExistence
Determine if does-exist should be performed on persist.protected static boolean
SmartMerge
Used for merging dependent values without use of WL SessionAccessorstatic int
THROW_ALL_CONFORM_EXCEPTIONS
protected Object
transaction
PERF: Stores the JTA transaction to optimize activeUnitOfWork lookup.protected UnitOfWorkChangeSet
unitOfWorkChangeSet
This method is used to store the current changeSet for this UnitOfWork.protected Map<Object,Object>
unregisteredDeletedObjectsCloneToBackupAndOriginal
Used to store objects already deleted from the db and unregisteredprotected Map<Object,Object>
unregisteredExistingObjects
protected Map<Object,Object>
unregisteredNewObjects
protected Map<Object,Object>
unregisteredNewObjectsInParent
protected int
validationLevel
The amount of validation can be configured.protected boolean
wasNonObjectLevelModifyQueryExecuted
True if either DataModifyQuery or ModifyAllQuery was executed.protected boolean
wasTransactionBegunPrematurely
Flag indicating that the transaction for this UOW was already begun.static int
WriteChangesFailed
-
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
Constructors Constructor Description UnitOfWorkImpl()
INTERNAL:UnitOfWorkImpl(AbstractSession parent, ReferenceMode referenceMode)
INTERNAL: Create and return a new unit of work with the session as its parent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Session
acquireHistoricalSession(AsOfClause clause)
INTERNAL: Acquires a special historical session for reading objects as of a past time.UnitOfWorkImpl
acquireUnitOfWork()
PUBLIC: Return a nested unit of work for this unit of work.protected void
acquireWriteLocks()
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.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
addToChangeTrackedHardList(Object obj)
void
afterExternalTransactionRollback()
INTERNAL: Called after external transaction rolled back.void
assignSequenceNumber(Object object)
ADVANCED: Assign sequence number to the object.Object
assignSequenceNumber(Object object, ClassDescriptor descriptor)
INTERNAL: Assign sequence number to the object.void
assignSequenceNumbers()
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
basicPrintRegisteredObjects()
INTERNAL: Print the objects in the unit of work.void
beginEarlyTransaction()
PUBLIC: Tell the unit of work to begin a transaction now.void
beginTransaction()
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow.Object
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.UnitOfWorkChangeSet
calculateChanges(Map registeredObjects, UnitOfWorkChangeSet changeSet, boolean assignSequences, boolean shouldCloneMap)
INTERNAL:protected boolean
canChangeReadOnlySet()
INTERNAL: Checks whether the receiver has been used.Object
checkExistence(Object object)
INTERNAL: Register the object and return the clone if it is existing otherwise return null if it is new.boolean
checkForUnregisteredExistingObject(Object object)
INTERNAL: Return if the object is an existing object (but has not been registered), or a new object (that has not be persisted).Object
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.Object
cloneAndRegisterObject(Object original, CacheKey parentCacheKey, ClassDescriptor descriptor)
INTERNAL: Clone and register the object.Object
cloneAndRegisterObject(Object original, CacheKey parentCacheKey, CacheKey unitOfWorkCacheKey, ClassDescriptor descriptor)
INTERNAL: Clone and register the object.protected Map
cloneMap(Map map)
This method is used internally to clone a map that holds the persistenceContexts.Map
collectAndPrepareObjectsForNestedMerge()
INTERNAL: Prepare for merge in nested uow.void
commit()
PUBLIC: Commit the unit of work to its parent.protected void
commitAfterWriteChanges()
INTERNAL: Commits a UnitOfWork where the commit process has already been initiated by all call to writeChanges().void
commitAndResume()
PUBLIC: Commit the unit of work to its parent.protected void
commitAndResumeAfterWriteChanges()
INTERNAL: Commits and resumes a UnitOfWork where the commit process has already been initiated by all call to writeChanges().void
commitAndResumeOnFailure()
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
commitInternallyStartedExternalTransaction()
PROTECTED: Used in commit and commit-like methods to commit internally started external transactionprotected void
commitNestedUnitOfWork()
INTERNAL: Commit the changes to any objects to the parent.void
commitRootUnitOfWork()
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
commitTransaction()
INTERNAL: This is internal to the uow, transactions should not be used explicitly in a uow.void
commitTransactionAfterWriteChanges()
INTERNAL: After writeChanges() everything has been done except for committing the transaction.Vector
copyReadOnlyClasses()
INTERNAL: Copy the read only classes from the unit of work.DatabaseValueHolder
createCloneQueryValueHolder(ValueHolderInterface attributeValue, Object clone, AbstractRecord row, ForeignReferenceMapping mapping)
DatabaseValueHolder
createCloneTransformationValueHolder(ValueHolderInterface attributeValue, Object original, Object clone, AbstractTransformationMapping mapping)
protected Map
createMap()
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.Object
deepMergeClone(Object rmiClone)
PUBLIC: Merge the attributes of the clone into the unit of work copy.Object
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
discoverAllUnregisteredNewObjects()
INTERNAL: Search for any objects in the parent that have not been registered.protected void
discoverAllUnregisteredNewObjectsInParent()
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
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.Object
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.Accessor
getAccessor()
INTERNAL: The uow does not store a local accessor but shares its parents.Collection<Accessor>
getAccessors()
INTERNAL: The uow does not store a local accessor but shares its parents.Collection<Accessor>
getAccessors(Call call, AbstractRecord translationRow, DatabaseQuery query)
INTERNAL: Return the connections to use for the query execution.UnitOfWork
getActiveUnitOfWork()
PUBLIC: Return the active unit of work for the current active external (JTS) transaction.Vector
getAllFromNewObjects(Expression selectionCriteria, Class theClass, AbstractRecord translationRow, int valueHolderPolicy)
INTERNAL: Return any new objects matching the expression.Object
getBackupClone(Object clone)
INTERNAL: Return the backup clone for the working clone.Object
getBackupClone(Object clone, ClassDescriptor descriptor)
INTERNAL: Return the backup clone for the working clone.Object
getBackupCloneForCommit(Object clone)
INTERNAL: Return the backup clone for the working clone.Object
getBackupCloneForCommit(Object clone, ClassDescriptor descriptor)
INTERNAL: Return the backup clone for the working clone.Map<ReadQuery,ReadQuery>
getBatchQueries()
INTERNAL: When in transaction batch read objects must use query local to the unit of work.Set<Object>
getCascadeDeleteObjects()
INTERNAL: Return any objects have been deleted through database cascade delete constraints.Set<Object>
getChangeTrackedHardList()
INTERNAL: Return the list of object with changes.Map
getCloneMapping()
INTERNAL: Return the clone mapping.Map
getCloneToOriginals()
INTERNAL: Map used to avoid garbage collection in weak caches.CommitManager
getCommitManager()
INTERNAL: The commit manager is used to resolve referential integrity on commits of multiple objects.UnitOfWork.CommitOrderType
getCommitOrder()
ADVANCED: Return the commit order.Map
getContainerBeans()
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.UnitOfWorkImpl
getContainerUnitOfWork()
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.UnitOfWorkChangeSet
getCurrentChanges()
ADVANCED: This method Will Calculate the changes for the UnitOfWork.Vector
getDefaultReadOnlyClasses()
INTERNAL: Returns the set of read-only classes that gets assigned to each newly created UnitOfWork.Map
getDeletedObjects()
INTERNAL: The deleted objects stores any objects removed during the unit of work.Map<Object,Set<Object>>
getDeletionDependencies()
INTERNAL: Return deleted objects that have reference to other deleted objects.Set<Object>
getDeletionDependencies(Object deletedObject)
INTERNAL: Return references to other deleted objects for this deleted object.AbstractSession
getExecutionSession(DatabaseQuery query)
INTERNAL: Gets the session which this query will be executed on.int
getLifecycle()
INTERNAL: The life cycle tracks if the unit of work is active and is used for JTS.MergeManager
getMergeManager()
A reference to the last used merge manager.Map
getNewAggregates()
INTERNAL: The map stores any new aggregates that have been cloned.Map
getNewObjectsCloneToMergeOriginal()
INTERNAL: The stores a map from new object clones to the original object used from merge.Map
getNewObjectsCloneToOriginal()
INTERNAL: The new objects stores any objects newly created during the unit of work.Map
getNewObjectsInParentOriginalToClone()
INTERNAL: The returns the list that will hold the new objects from the Parent UnitOfWorkMap
getNewObjectsOriginalToClone()
INTERNAL: The new objects stores any objects newly created during the unit of work.Object
getObjectFromNewObjects(Class theClass, Object selectionKey)
INTERNAL: Return any new object matching the expression.Object
getObjectFromNewObjects(Expression selectionCriteria, Class theClass, AbstractRecord translationRow, int valueHolderPolicy)
INTERNAL: Return any new object matching the expression.Map
getObjectsDeletedDuringCommit()
INTERNAL: Returns all the objects which are deleted during root commit of unit of work.Map
getOptimisticReadLockObjects()
INTERNAL: Return optimistic read lock objectsObject
getOriginalVersionOfNewObject(Object workingClone)
INTERNAL: Return the original version of the new object (working clone).Object
getOriginalVersionOfObject(Object workingClone)
ADVANCED: Return the original version of the object(clone) from the parent's identity map.Object
getOriginalVersionOfObjectOrNull(Object workingClone, ClassDescriptor descriptor)
INTERNAL: Return the original version of the object(clone) from the parent's identity map.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.AbstractSession
getParent()
PUBLIC: Return the parent.AbstractSession
getParentIdentityMapSession(ClassDescriptor descriptor, boolean canReturnSelf, boolean terminalOnly)
INTERNAL: Returns the appropriate IdentityMap session for this descriptor.Map
getPessimisticLockedObjects()
INTERNAL:Platform
getPlatform(Class domainClass)
INTERNAL: Return the platform for a particular class.Object
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.DatabaseQuery
getQuery(String name)
PUBLIC: Return the query from the session pre-defined queries with the given name.DatabaseQuery
getQuery(String name, Vector arguments)
PUBLIC: Return the query from the session pre-defined queries with the given name.Set
getReadOnlyClasses()
ADVANCED: Returns the set of read-only classes in this UnitOfWork.Object
getReference(Class theClass, Object id)
Get an instance, whose state may be lazily fetched.ReferenceMode
getReferenceMode()
protected Map
getRemovedObjects()
INTERNAL: The removed objects stores any newly registered objects removed during the nested unit of work.Sequencing
getSequencing()
INTERNAL: Return the Sequencing object used by the session.ServerPlatform
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.String
getSessionTypeString()
INTERNAL: Returns the type of session, its class.int
getShouldThrowConformExceptions()
INTERNAL: Return whether to throw exceptions on conforming queriesint
getState()
INTERNAL: Find out what the lifecycle state of this UoW is in.Object
getTransaction()
INTERNAL: PERF: Return the associated external transaction.UnitOfWorkChangeSet
getUnitOfWorkChangeSet()
ADVANCED: Returns the currentChangeSet from the UnitOfWork.Map
getUnregisteredExistingObjects()
INTERNAL: Used to lazy Initialize the unregistered existing Objects collection.protected 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.protected Map
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.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.boolean
hasCascadeDeleteObjects()
INTERNAL: Return if any objects have been deleted through database cascade delete constraints.boolean
hasChanges()
ADVANCED: The Unit of work is capable of preprocessing to determine if any on the clone have been changed.boolean
hasCloneMapping()
INTERNAL: Return if the unit of work has any clones.protected boolean
hasCloneToOriginals()
boolean
hasContainerBeans()
INTERNAL: Return if any container beans exist.protected boolean
hasDeferredModifyAllQueries()
boolean
hasDeletedObjects()
INTERNAL: The deleted objects stores any objects removed during the unit of work.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.protected boolean
hasModifyAllQueries()
boolean
hasNewObjects()
INTERNAL: Return if there are any registered new objects.protected boolean
hasNewObjectsInParentOriginalToClone()
protected boolean
hasObjectsDeletedDuringCommit()
boolean
hasOptimisticReadLockObjects()
INTERNAL: Return if there are any optimistic read locks.boolean
hasPessimisticLockedObjects()
INTERNAL: Return true if there are any pessimistic locked objects in this unit of work, false otherwise.boolean
hasPrivateOwnedObjects()
INTERNAL: Return true if privateOwnedObjects is not null and not empty, false otherwise.protected boolean
hasRemovedObjects()
boolean
hasUnregisteredNewObjects()
INTERNAL: Return if there are any unregistered new objects.void
initializeIdentityMapAccessor()
INTERNAL: Set up the IdentityMapManager.Object
internalExecuteQuery(DatabaseQuery query, AbstractRecord databaseRow)
INTERNAL: Return the results from executing the database query.Object
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
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.protected boolean
isAfterWriteChangesFailed()
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
isCommitPending()
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
isInTransaction()
PUBLIC: Return whether the session currently has a database transaction in progress.boolean
isMergePending()
INTERNAL: Return if the unit of work is waiting to be merged or in the process of being merged.boolean
isNestedUnitOfWork()
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
isPreDeleteComplete()
static boolean
isSmartMerge()
INTERNAL: Return the status of smart mergeprotected void
issueModifyAllQueryList()
INTERNAL: Will notify all the deferred ModifyAllQuery's (excluding UpdateAllQuery's) and deferred UpdateAllQuery's to execute.void
issueSQLbeforeCompletion()
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
isUnitOfWork()
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
mergeBmpAndWsEntities()
INTERNAL: BMP and Websphere CMP entities have to be merged if they are registered in the unit of work.protected void
mergeChangesIntoParent()
INTERNAL: Merge the changes to all objects to the parent.Object
mergeClone(Object rmiClone)
PUBLIC: Merge the attributes of the clone into the unit of work copy.Object
mergeClone(Object rmiClone, int cascadeDepth, boolean forRefresh)
INTERNAL: Merge the attributes of the clone into the unit of work copy.void
mergeClonesAfterCompletion()
INTERNAL: for synchronized units of work, merge changes into parentObject
mergeCloneWithReferences(Object rmiClone)
PUBLIC: Merge the attributes of the clone into the unit of work copy.Object
mergeCloneWithReferences(Object rmiClone, int cascadePolicy)
PUBLIC: Merge the attributes of the clone into the unit of work copy.Object
mergeCloneWithReferences(Object rmiClone, int cascadePolicy, boolean forceCascade)
INTERNAL: Merge the attributes of the clone into the unit of work copy.Object
mergeCloneWithReferences(Object rmiClone, MergeManager manager)
INTERNAL: Merge the attributes of the clone into the unit of work copy.Object
newInstance(Class theClass)
PUBLIC: Return a new instance of the class registered in this unit of work.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.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.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
preMergeChanges()
INTERNAL: Remove objects deleted during commit from clone and new object cache so that these are not mergedvoid
printRegisteredObjects()
PUBLIC: Print the objects in the unit of work.Object
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 duplicationVector
registerAllObjects(Collection domainObjects)
PUBLIC: Register the objects with the unit of work.Vector
registerAllObjects(Vector domainObjects)
PUBLIC: Register the objects with the unit of work.Object
registerExistingObject(Object existingObject)
ADVANCED: Register the existing object with the unit of work.Object
registerExistingObject(Object existingObject, boolean isFromSharedCache)
ADVANCED: Register the existing object with the unit of work.Object
registerExistingObject(Object objectToRegister, ClassDescriptor descriptor, Object queryPrimaryKey, boolean isFromSharedCache)
INTERNAL: Register the existing object with the unit of work.Object
registerNewContainerBean(Object newObject)
INTERNAL: Register the new container bean with the unit of work.Object
registerNewContainerBeanForCMP(Object newObject)
INTERNAL: Register the new Bean with the unit of work.Object
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.Object
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
registerWithTransactionIfRequired()
INTERNAL: Register this UnitOfWork against an external transaction controllervoid
release()
PUBLIC: Release the unit of work.void
releaseJTSConnection()
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
releaseWriteLocks()
INTERNAL: Release the unit of work cache write locks, if acquired.void
removeAllReadOnlyClasses()
PUBLIC: Empties the set of read-only classes.void
removeForceUpdateToVersionField(Object lockObject)
ADVANCED: Remove optimistic read lock from the object See forceUpdateToVersionField(Object)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
resumeUnitOfWork()
INTERNAL: Resume the unit of work state after a flush, or resume operation.Object
retryQuery(DatabaseQuery query, AbstractRecord row, DatabaseException databaseException, int retryCount, AbstractSession executionSession)
INTERNAL: A query execution failed due to an invalid query.void
revertAndResume()
PUBLIC: Revert all changes made to any registered object.Object
revertObject(Object clone)
PUBLIC: Revert the object's attributes from the parent.Object
revertObject(Object clone, int cascadeDepth)
INTERNAL: Revert the object's attributes from the parent.void
rollbackTransaction()
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.Map<Object,Object>
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
setCommitOrder(UnitOfWork.CommitOrderType order)
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
setPendingMerge()
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: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.Object
shallowMergeClone(Object rmiClone)
PUBLIC: Merge the attributes of the clone into the unit of work copy.Object
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
shouldCascadeCloneToJoinedRelationship()
INTERNAL: True if the value holder for the joined attribute should be triggered.boolean
shouldClearForCloseOnRelease()
INTERNAL: Indicates whether clearForClose method should be called by release method.boolean
shouldDiscoverNewObjects()
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
shouldNewObjectsBeCached()
ADVANCED: By default new objects are not cached until the exist on the database.boolean
shouldPerformDeletesFirst()
ADVANCED: By default all objects are inserted and updated in the database before any object is deleted.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.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.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.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).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 controlboolean
shouldStoreBypassCache()
INTERNAL: This is a JPA setting that is off by default in regular EclipseLink.boolean
shouldValidateExistence()
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
synchronizeAndResume()
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
validateObjectSpace()
ADVANCED: This can be used to help debugging an object-space corruption.boolean
verifyMutexThreadIntegrityBeforeRelease()
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
wasNonObjectLevelModifyQueryExecuted()
INTERNAL: True if either DataModifyQuery or ModifyAllQuery was executed.boolean
wasTransactionBegunPrematurely()
INTERNAL: Indicates if a transaction was begun by a pessimistic locking or non-selecting query.void
writeChanges()
ADVANCED: Writes all changes now before commit().void
writesCompleted()
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 Detail
-
CREATION_THREAD_ID
public final long CREATION_THREAD_ID
-
CREATION_THREAD_NAME
public final String CREATION_THREAD_NAME
-
CREATION_THREAD_HASHCODE
public final long CREATION_THREAD_HASHCODE
-
cloneToOriginals
protected transient Map<Object,Object> cloneToOriginals
As well as used as lookup in merge algorithm for aggregates and others
-
parent
protected transient AbstractSession parent
-
cloneMapping
protected Map<Object,Object> cloneMapping
Map of all the clones. The key contains the clone of the object.
-
newObjectsCloneToMergeOriginal
protected Map<Object,Object> newObjectsCloneToMergeOriginal
Stores a map from the clone to the original merged object, as a different instance is used as the original for merges.
-
allClones
protected Map<Object,Object> allClones
This member variable contains a copy of all of the clones for this particular UOW
-
privateOwnedObjects
protected Map<DatabaseMapping,Set> privateOwnedObjects
Cache references of private owned objects for the removal of private owned orphans
-
newObjectsInParent
protected Map<Object,Object> newObjectsInParent
used to store a list of the new objects in the parent
-
unitOfWorkChangeSet
protected UnitOfWorkChangeSet unitOfWorkChangeSet
This method is used to store the current changeSet for this UnitOfWork.
-
containerUnitOfWork
protected UnitOfWorkImpl containerUnitOfWork
This is only used for EJB entity beans to manage beans accessed in a transaction context.
-
pessimisticLockedObjects
protected Map<Object,Object> pessimisticLockedObjects
use to track pessimistic locked objects
-
lastUsedMergeManager
protected transient MergeManager lastUsedMergeManager
Used to store the list of locks that this UnitOfWork has acquired for this merge
-
batchQueries
protected Map<ReadQuery,ReadQuery> batchQueries
When in transaction batch read objects must use query local to the unit of work.
-
readOnlyClasses
protected Set<Class> readOnlyClasses
Read-only class can be used for reference data to avoid cloning when not required.
-
wasTransactionBegunPrematurely
protected boolean wasTransactionBegunPrematurely
Flag indicating that the transaction for this UOW was already begun.
-
shouldNewObjectsBeCached
protected boolean shouldNewObjectsBeCached
Allow for double merges of new objects by putting them into the cache.
-
shouldPerformDeletesFirst
protected boolean shouldPerformDeletesFirst
Flag indicating that deletes should be performed before other updates.
-
shouldThrowConformExceptions
protected int shouldThrowConformExceptions
Flag indicating how to deal with exceptions on conforming queries.
-
validationLevel
protected int validationLevel
The amount of validation can be configured.
-
None
public static final int None
- See Also:
- Constant Field Values
-
Partial
public static final int Partial
- See Also:
- Constant Field Values
-
Full
public static final int Full
- See Also:
- Constant Field Values
-
lifecycle
protected int lifecycle
With 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:
- Constant Field Values
-
CommitPending
public static final int CommitPending
- See Also:
- Constant Field Values
-
CommitTransactionPending
public static final int CommitTransactionPending
- See Also:
- Constant Field Values
-
WriteChangesFailed
public static final int WriteChangesFailed
- See Also:
- Constant Field Values
-
MergePending
public static final int MergePending
- See Also:
- Constant Field Values
-
Death
public static final int Death
- See Also:
- Constant Field Values
-
AfterExternalTransactionRolledBack
public static final int AfterExternalTransactionRolledBack
- See Also:
- Constant Field Values
-
DO_NOT_THROW_CONFORM_EXCEPTIONS
public static final int DO_NOT_THROW_CONFORM_EXCEPTIONS
Used for Conforming Queries- See Also:
- Constant Field Values
-
THROW_ALL_CONFORM_EXCEPTIONS
public static final int THROW_ALL_CONFORM_EXCEPTIONS
- See Also:
- Constant Field Values
-
LOCK_QUERIES_PROPERTY
public static final String LOCK_QUERIES_PROPERTY
- See Also:
- Constant Field Values
-
SmartMerge
protected static boolean SmartMerge
Used for merging dependent values without use of WL SessionAccessor
-
optimisticReadLockObjects
protected Map<Object,Object> optimisticReadLockObjects
Kept reference of read lock objects
-
ReadLockOnly
public static final String ReadLockOnly
Used for read lock to determine update the version field with the same value or increment value- See Also:
- Constant Field Values
-
ReadLockUpdateVersion
public static final String ReadLockUpdateVersion
- See Also:
- Constant Field Values
-
modifyAllQueries
protected List<ModifyAllQuery> 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
protected List<Object[]> 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 cloneDepth
Used 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
protected Object transaction
PERF: Stores the JTA transaction to optimize activeUnitOfWork lookup.
-
resumeOnTransactionCompletion
protected boolean resumeOnTransactionCompletion
True if UnitOfWork should be resumed on completion of transaction. Used when UnitOfWork is Synchronized with external transaction control
-
shouldDiscoverNewObjects
protected boolean shouldDiscoverNewObjects
PERF: Allows discover new objects to be skipped if app always calls persist.
-
wasNonObjectLevelModifyQueryExecuted
protected boolean wasNonObjectLevelModifyQueryExecuted
True if either DataModifyQuery or ModifyAllQuery was executed. Gets reset on commit, effects DoesExistQuery behavior and reading.
-
shouldCascadeCloneToJoinedRelationship
protected boolean shouldCascadeCloneToJoinedRelationship
True if the value holder for the joined attribute should be triggered. Required by ejb30 fetch join.
-
isNestedUnitOfWork
protected boolean isNestedUnitOfWork
PERF: Cache isNestedUnitOfWork check.
-
shouldValidateExistence
protected boolean shouldValidateExistence
Determine if does-exist should be performed on persist.
-
commitOrder
protected UnitOfWork.CommitOrderType commitOrder
Allow updates and deletes to be ordered by id or changes to avoid possible deadlocks.
-
referenceMode
protected ReferenceMode 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.
-
unregisteredDeletedObjectsCloneToBackupAndOriginal
protected Map<Object,Object> unregisteredDeletedObjectsCloneToBackupAndOriginal
Used to store objects already deleted from the db and unregistered
-
preDeleteComplete
protected boolean preDeleteComplete
This attribute records when the preDelete stage of Commit has completed
-
deletedPrivateOwnedObjects
protected Map<DatabaseMapping,List<Object>> deletedPrivateOwnedObjects
Stores all of the private owned objects that have been removed and may need to cascade deletion
-
mergeManagerForActiveMerge
protected transient MergeManager mergeManagerForActiveMerge
temporarily holds a reference to a merge manager that is calling this UnitOfWork during merge
-
cascadeDeleteObjects
protected Set<Object> cascadeDeleteObjects
Set of objects that were deleted by database cascade delete constraints.
-
-
Constructor Detail
-
UnitOfWorkImpl
public UnitOfWorkImpl()
INTERNAL:
-
UnitOfWorkImpl
public UnitOfWorkImpl(AbstractSession parent, ReferenceMode referenceMode)
INTERNAL: Create and return a new unit of work with the session as its parent.
-
-
Method Detail
-
acquireHistoricalSession
public Session acquireHistoricalSession(AsOfClause clause) throws ValidationException
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:
AsOfClause
,Expression.asOf(org.eclipse.persistence.history.AsOfClause)
,ObjectLevelReadQuery.setAsOfClause(org.eclipse.persistence.history.AsOfClause)
,HistoryPolicy
-
acquireUnitOfWork
public UnitOfWorkImpl 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:
UnitOfWorkImpl
-
addDeletedPrivateOwnedObjects
public 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.
-
addNewAggregate
public void addNewAggregate(Object originalObject)
INTERNAL: Register a new aggregate object with the unit of work.
-
addObjectDeletedDuringCommit
public void addObjectDeletedDuringCommit(Object object, ClassDescriptor descriptor)
INTERNAL: Add object deleted during root commit of unit of work.
-
addReadOnlyClass
public void addReadOnlyClass(Class theClass) throws ValidationException
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 void addReadOnlyClasses(Collection classes)
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
public void addRemovedObject(Object orignal)
INTERNAL: Register that an object was removed in a nested unit of work.
-
assignSequenceNumber
public void assignSequenceNumber(Object object) throws DatabaseException
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
public void assignSequenceNumbers() throws DatabaseException
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
protected void assignSequenceNumbers(Map objects) throws DatabaseException
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 void beginEarlyTransaction() throws DatabaseException
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:
commit()
,release()
-
beginTransaction
public void beginTransaction() throws DatabaseException
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:
AbstractSession.isInTransaction()
-
buildOriginal
public Object 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. 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
public boolean checkForUnregisteredExistingObject(Object object)
INTERNAL: Return if the object is an existing object (but has not been registered), or a new object (that has not be persisted).
-
checkExistence
public Object checkExistence(Object object)
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
public Object checkIfAlreadyRegistered(Object object, ClassDescriptor descriptor)
INTERNAL: Return the value of the object if it already is registered, otherwise null.
-
isConsideredInvalid
public boolean isConsideredInvalid(Object object, CacheKey cacheKey, ClassDescriptor descriptor)
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
protected Object cloneAndRegisterNewObject(Object original, boolean isShallowClone)
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:
registerObject(Object)
-
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
public Map collectAndPrepareObjectsForNestedMerge()
INTERNAL: Prepare for merge in nested uow.
-
commit
public void commit() throws DatabaseException, OptimisticLockException
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:
commitAndResumeOnFailure()
,commitAndResume()
,release()
-
commitAndResume
public void commitAndResume() throws DatabaseException, OptimisticLockException
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:
commitAndResumeOnFailure()
,commit()
,release()
-
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 void commitAndResumeOnFailure() throws DatabaseException, OptimisticLockException
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:
commit()
,release()
-
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
public void commitRootUnitOfWork() throws DatabaseException, OptimisticLockException
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
public void commitTransaction() throws DatabaseException
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
public Vector copyReadOnlyClasses()
INTERNAL: Copy the read only classes from the unit of work.- Overrides:
copyReadOnlyClasses
in classAbstractSession
-
deepMergeClone
public Object deepMergeClone(Object rmiClone)
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:
mergeClone(Object)
,shallowMergeClone(Object)
-
deepRevertObject
public Object deepRevertObject(Object clone)
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:
revertObject(Object)
,shallowRevertObject(Object)
-
deepUnregisterObject
public void deepUnregisterObject(Object clone)
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
public void forceUpdateToVersionField(Object lockObject, boolean shouldModifyVersionField)
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
public Accessor getAccessor()
INTERNAL: The uow does not store a local accessor but shares its parents.- Overrides:
getAccessor
in classAbstractSession
-
getAccessors
public Collection<Accessor> getAccessors()
INTERNAL: The uow does not store a local accessor but shares its parents.- Overrides:
getAccessors
in classAbstractSession
-
getCommitManager
public CommitManager 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 UnitOfWork 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
public Object getBackupClone(Object clone) throws QueryException
INTERNAL: Return the backup clone for the working clone.- Throws:
QueryException
-
getBackupClone
public Object getBackupClone(Object clone, ClassDescriptor descriptor) throws QueryException
INTERNAL: Return the backup clone for the working clone.- Throws:
QueryException
-
getBackupCloneForCommit
public Object getBackupCloneForCommit(Object clone, ClassDescriptor descriptor)
INTERNAL: Return the backup clone for the working clone.
-
getBackupCloneForCommit
public Object getBackupCloneForCommit(Object clone)
INTERNAL: Return the backup clone for the working clone.
-
getCurrentChanges
public UnitOfWorkChangeSet 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
public AbstractSession getExecutionSession(DatabaseQuery query)
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
public Map 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
public Map 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
public Map 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
public Set<Object> getCascadeDeleteObjects()
INTERNAL: Return any objects have been deleted through database cascade delete constraints.
-
setCascadeDeleteObjects
protected void setCascadeDeleteObjects(Set<Object> cascadeDeleteObjects)
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
public UnitOfWorkImpl getContainerUnitOfWork()
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.
-
getDefaultReadOnlyClasses
public Vector getDefaultReadOnlyClasses()
INTERNAL: Returns the set of read-only classes that gets assigned to each newly created UnitOfWork.- Overrides:
getDefaultReadOnlyClasses
in classAbstractSession
- See Also:
Project.setDefaultReadOnlyClasses(Collection)
-
getDeletedObjects
public Map 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
public MergeManager getMergeManager()
A reference to the last used merge manager. This is used to track locked objects.
-
getNewAggregates
public Map getNewAggregates()
INTERNAL: The map stores any new aggregates that have been cloned.
-
getNewObjectsCloneToOriginal
public Map 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.
-
getNewObjectsCloneToMergeOriginal
public Map getNewObjectsCloneToMergeOriginal()
INTERNAL: The stores a map from new object clones to the original object used from merge.
-
getNewObjectsInParentOriginalToClone
public Map 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
public Map 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
public Sequencing getSequencing()
INTERNAL: Return the Sequencing object used by the session.- Overrides:
getSequencing
in classAbstractSession
-
getServerPlatform
public ServerPlatform 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
public String 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
public Object getObjectFromNewObjects(Class theClass, Object selectionKey)
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
public Map getObjectsDeletedDuringCommit()
INTERNAL: Returns all the objects which are deleted during root commit of unit of work.
-
hasObjectsDeletedDuringCommit
protected boolean hasObjectsDeletedDuringCommit()
-
getOptimisticReadLockObjects
public Map getOptimisticReadLockObjects()
INTERNAL: Return optimistic read lock objects
-
getOriginalVersionOfNewObject
public Object getOriginalVersionOfNewObject(Object workingClone)
INTERNAL: Return the original version of the new object (working clone).
-
getOriginalVersionOfObject
public Object getOriginalVersionOfObject(Object workingClone)
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
public Object getOriginalVersionOfObjectOrNull(Object workingClone, ClassDescriptor descriptor)
INTERNAL: Return the original version of the object(clone) from the parent's identity map.
-
getParent
public AbstractSession 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
public Object 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.- Specified by:
getProperty
in interfaceSession
- Overrides:
getProperty
in classAbstractSession
-
getPlatform
public Platform getPlatform(Class domainClass)
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 DatabaseQuery getQuery(String name, Vector arguments)
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:
AbstractSession.getQuery(String)
-
getQuery
public DatabaseQuery getQuery(String name)
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
public Set getReadOnlyClasses()
ADVANCED: Returns the set of read-only classes in this UnitOfWork.- Specified by:
getReadOnlyClasses
in interfaceUnitOfWork
-
getRemovedObjects
protected Map 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
public Object getTransaction()
INTERNAL: PERF: Return the associated external transaction. Used to optimize activeUnitOfWork lookup.
-
setTransaction
public void setTransaction(Object transaction)
INTERNAL: PERF: Set the associated external transaction. Used to optimize activeUnitOfWork lookup.
-
getUnitOfWorkChangeSet
public UnitOfWorkChangeSet getUnitOfWorkChangeSet()
ADVANCED: Returns the currentChangeSet from the UnitOfWork. This is only valid after the UnitOfWOrk has committed successfully- Specified by:
getUnitOfWorkChangeSet
in interfaceUnitOfWork
-
getUnregisteredExistingObjects
public Map getUnregisteredExistingObjects()
INTERNAL: Used to lazy Initialize the unregistered existing Objects collection.- Returns:
- Map
-
getUnregisteredNewObjects
protected 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
protected Map 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
public boolean isClassReadOnly(Class theClass, ClassDescriptor descriptor)
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
public boolean isCloneNewObjectFromParent(Object clone)
INTERNAL: Check if the object is already registered in a parent Unit Of Work
-
isCloneNewObject
public boolean isCloneNewObject(Object clone)
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
public boolean isNewObjectInParent(Object clone)
INTERNAL: This method determines if the specified clone is new in the parent UnitOfWork
-
isObjectDeleted
public boolean isObjectDeleted(Object object)
INTERNAL: Return if the object has been deleted in this unit of work.
-
isObjectNew
public boolean isObjectNew(Object clone)
INTERNAL: This method is used to determine if the clone is a new Object in the UnitOfWork
-
isUnregisteredExistingObject
public boolean isUnregisteredExistingObject(Object object)
INTERNAL: Return if the object is a known unregistered existing object.
-
isObjectRegistered
public boolean isObjectRegistered(Object clone)
ADVANCED: Return whether the clone object is already registered.- Specified by:
isObjectRegistered
in interfaceUnitOfWork
-
isOriginalNewObject
public boolean isOriginalNewObject(Object original)
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
public boolean isUnregisteredNewObjectInParent(Object originalObject)
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 Object mergeClone(Object rmiClone)
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:
shallowMergeClone(Object)
,deepMergeClone(Object)
-
mergeClone
public Object mergeClone(Object rmiClone, int cascadeDepth, boolean forRefresh)
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 Object mergeCloneWithReferences(Object rmiClone)
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:
shallowMergeClone(Object)
,deepMergeClone(Object)
-
mergeCloneWithReferences
public Object mergeCloneWithReferences(Object rmiClone, int cascadePolicy)
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:
shallowMergeClone(Object)
,deepMergeClone(Object)
-
mergeCloneWithReferences
public Object mergeCloneWithReferences(Object rmiClone, int cascadePolicy, boolean forceCascade)
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:
shallowMergeClone(Object)
,deepMergeClone(Object)
-
mergeCloneWithReferences
public Object mergeCloneWithReferences(Object rmiClone, MergeManager manager)
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:
shallowMergeClone(Object)
,deepMergeClone(Object)
-
newInstance
public Object newInstance(Class theClass)
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
public 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. 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
public void performRemovePrivateOwnedObjectFromChangeSet(Object toBeRemoved, Map visitedObjects)
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
protected void postMergeChanges(Set classesChanged)
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
public Object 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 duplication
-
basicPrintRegisteredObjects
protected void basicPrintRegisteredObjects()
INTERNAL: Print the objects in the unit of work.
-
registerAllObjects
public Vector registerAllObjects(Collection domainObjects)
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
public Object registerExistingObject(Object existingObject)
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
public Object registerExistingObject(Object existingObject, boolean isFromSharedCache)
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
public Object registerNewContainerBean(Object newObject)
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:
registerObject(Object)
-
registerNewContainerBeanForCMP
public Object registerNewContainerBeanForCMP(Object newObject)
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
public Object registerNewObject(Object newObject)
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:
registerObject(Object)
-
registerNewObject
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. 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:
registerObject(Object)
-
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:
newObjects
- any new objects found must be added to this collection.cascadePersist
- determines if this call is cascading from a cascadePersist mapping or not.
-
registerNewObjectForPersist
public void registerNewObjectForPersist(Object newObject, Map visitedObjects)
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:
registerObject(Object)
-
wasDeleted
public boolean wasDeleted(Object original)
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
protected void registerNewObjectClone(Object clone, Object original, ClassDescriptor descriptor)
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 Object registerObject(Object object)
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
protected Object registerObject(Object object, ClassDescriptor descriptor)
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:
commit()
-
removeAllReadOnlyClasses
public void removeAllReadOnlyClasses() throws ValidationException
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
public void removeForceUpdateToVersionField(Object lockObject)
ADVANCED: Remove optimistic read lock from the object See forceUpdateToVersionField(Object)- Specified by:
removeForceUpdateToVersionField
in interfaceUnitOfWork
-
removePrivateOwnedObject
public void removePrivateOwnedObject(DatabaseMapping mapping, Object privateOwnedObject)
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 void removeReadOnlyClass(Class theClass) throws ValidationException
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:
commitAndResume()
,release()
-
revertObject
public Object revertObject(Object clone)
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:
shallowRevertObject(Object)
,deepRevertObject(Object)
-
revertObject
public Object revertObject(Object clone, int cascadeDepth)
INTERNAL: Revert the object's attributes from the parent. This uses merging to merge the object changes.
-
rollbackTransaction
public void rollbackTransaction() throws DatabaseException
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
protected void rollbackTransaction(boolean intendedToCommitTransaction) throws DatabaseException
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
protected void setAllClonesCollection(Map objects)
INTERNAL: Used to set the collections of all objects in the UnitOfWork.- Parameters:
objects
-
-
setCloneMapping
protected void setCloneMapping(Map cloneMapping)
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
protected void setContainerBeans(Map containerBeans)
INTERNAL: This is only used for EJB entity beans to manage beans accessed in a transaction context.
-
setContainerUnitOfWork
protected void setContainerUnitOfWork(UnitOfWorkImpl containerUnitOfWork)
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
protected void setDeletedObjects(Map deletedObjects)
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
public void setMergeManager(MergeManager mergeManager)
INTERNAL: A reference to the last used merge manager. This is used to track locked objects.
-
setNewObjectsCloneToOriginal
protected void setNewObjectsCloneToOriginal(Map newObjects)
INTERNAL: The new objects stores any objects newly created during the unit of work. On commit they will all be inserted into the database.
-
setNewObjectsOriginalToClone
protected void setNewObjectsOriginalToClone(Map newObjects)
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
public void setObjectsDeletedDuringCommit(Map deletedObjects)
INTERNAL: Set the objects that have been deleted.
-
setParent
public void setParent(AbstractSession parent)
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
public void setReadOnlyClasses(List<Class> classes)
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
protected void setRemovedObjects(Map removedObjects)
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
public boolean shouldForceReadFromDB(ObjectBuildingQuery query, Object primaryKey)
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:
RepeatableWriteUnitOfWork
-
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
public void setUnitOfWorkChangeSet(UnitOfWorkChangeSet unitOfWorkChangeSet)
INTERNAL: Sets the current UnitOfWork change set to be the one passed in.
-
setUnregisteredExistingObjects
protected void setUnregisteredExistingObjects(Map newUnregisteredExistingObjects)
INTERNAL: Used to set the unregistered existing objects vector used when validation has been turned off.- Parameters:
newUnregisteredExistingObjects
- Map
-
setUnregisteredNewObjects
protected void setUnregisteredNewObjects(Map newObjects)
INTERNAL:
-
setUnregisteredNewObjectsInParent
protected void setUnregisteredNewObjectsInParent(Map newObjects)
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 Object shallowMergeClone(Object rmiClone)
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:
mergeClone(Object)
,deepMergeClone(Object)
-
shallowRevertObject
public Object shallowRevertObject(Object clone)
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:
revertObject(Object)
,deepRevertObject(Object)
-
shallowUnregisterObject
public void shallowUnregisterObject(Object clone)
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:
RepeatableWriteUnitOfWork
-
storeModifyAllQuery
public void storeModifyAllQuery(DatabaseQuery query)
INTERNAL: Store the ModifyAllQuery's from the UoW in the list. They are always deferred to commit time
-
storeDeferredModifyAllQuery
public void storeDeferredModifyAllQuery(DatabaseQuery query, AbstractRecord translationRow)
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
protected void undeleteObject(Object object)
INTERNAL: This method is used to transition an object from the deleted objects list to be simply be register.
-
unregisterObject
public void unregisterObject(Object clone)
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
public void unregisterObject(Object clone, int cascadeDepth)
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
public void unregisterObject(Object clone, int cascadeDepth, boolean forDetach)
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
protected Object updateDerivedIds(Object clone, ClassDescriptor descriptor)
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
public Map<ReadQuery,ReadQuery> getBatchQueries()
INTERNAL: When in transaction batch read objects must use query local to the unit of work.
-
setBatchQueries
public void setBatchQueries(Map<ReadQuery,ReadQuery> batchQueries)
INTERNAL: When in transaction batch read objects must use query local to the unit of work.
-
getPessimisticLockedObjects
public Map getPessimisticLockedObjects()
INTERNAL:
-
addToChangeTrackedHardList
public void addToChangeTrackedHardList(Object obj)
-
addPessimisticLockedClone
public void addPessimisticLockedClone(Object clone)
INTERNAL:
-
addPrivateOwnedObject
public void addPrivateOwnedObject(DatabaseMapping mapping, Object privateOwnedObject)
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
public boolean isPessimisticLocked(Object clone)
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
public void releaseReadConnection(Accessor connection)
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
protected Map createMap()
This method is used internally to create a map to hold the persistenceContexts. A weak map is returned if ReferenceMode is weak.
-
createMap
protected Map createMap(int size)
This method is used internally to create a map to hold the persistenceContexts. A weak map is returned if ReferenceMode is weak.- Parameters:
size
-
-
cloneMap
protected Map cloneMap(Map map)
This method is used internally to clone a map that holds the persistenceContexts. A weak map is returned if ReferenceMode is weak.
-
getReferenceMode
public ReferenceMode getReferenceMode()
-
getChangeTrackedHardList
public Set<Object> getChangeTrackedHardList()
INTERNAL: Return the list of object with changes. This is used in weak reference mode to avoid garbage collection of changed objects.
-
getReference
public Object getReference(Class theClass, Object id)
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 DatabaseValueHolder createCloneQueryValueHolder(ValueHolderInterface attributeValue, Object clone, AbstractRecord row, ForeignReferenceMapping mapping)
- Overrides:
createCloneQueryValueHolder
in classAbstractSession
-
createCloneTransformationValueHolder
public DatabaseValueHolder createCloneTransformationValueHolder(ValueHolderInterface attributeValue, Object original, Object clone, AbstractTransformationMapping mapping)
- Overrides:
createCloneTransformationValueHolder
in classAbstractSession
-
getDeletionDependencies
public Map<Object,Set<Object>> 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
public void addDeletionDependency(Object target, Object source)
INTERNAL: Record deleted objects that have reference to other deleted objects. This is need to delete cycles of objects in the correct order.
-
getDeletionDependencies
public Set<Object> getDeletionDependencies(Object deletedObject)
INTERNAL: Return references to other deleted objects for this deleted object. This is need to delete cycles of objects in the correct order.
-
getCommitOrder
public UnitOfWork.CommitOrderType getCommitOrder()
ADVANCED: Return the commit order.- Specified by:
getCommitOrder
in interfaceUnitOfWork
-
setCommitOrder
public void setCommitOrder(UnitOfWork.CommitOrderType order)
ADVANCED: Set the commit order.- Specified by:
setCommitOrder
in interfaceUnitOfWork
-
-