public class UnitOfWorkImpl extends AbstractSession implements UnitOfWork
Purpose: To allow object level transactions.
Description: The unit of work is a session that implements all of the normal
protocol of a TopLink 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 opperate on its own object space, that is the objects within the unit of work
will be clones of the orignial objects. When the unit of work is commited, all changes to any objects
registered within the unit of work will be commited to the database. A minimal commit/update will
be performed and any foreign keys/circular reference/referencial 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 occured.
- Resolve foreign keys for newly created objects and maintain referencial integrity.
- Allow for the object transaction to use its own object space.
,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
AfterExternalTransactionRolledBack |
protected IdentityHashtable |
allClones
This member variable contains a copy of all of the clones for this particular UOW
|
static int |
Birth |
protected int |
cloneDepth
Used during the cloning process to track the recursive depth in.
|
protected IdentityHashtable |
cloneMapping
Hashtable of all the clones.
|
protected IdentityHashtable |
cloneToOriginals
As well as used as lookup in merge algorithm for aggregates and others
|
static int |
CommitPending |
static int |
CommitTransactionPending |
static int |
Death |
protected java.util.List |
deferredModifyAllQueries
Contains deferred ModifyAllQuery's that have translation row for execution only.
|
protected IdentityHashtable |
deletedObjects |
static int |
DO_NOT_THROW_CONFORM_EXCEPTIONS
Used for Conforming Queries
|
static int |
Full |
protected boolean |
isSynchronized
With the new synchronized unit of work, need a lifecycle state variable to
track birth, commited, pending_merge and death.
|
protected MergeManager |
lastUsedMergeManager
Used to store the list of locks that this UnitOfWork has acquired for this merge
|
protected int |
lifecycle |
static java.lang.String |
LOCK_QUERIES_PROPERTY |
static int |
MergePending |
protected java.util.List |
modifyAllQueries
lazy initialization done in storeModifyAllQuery.
|
protected IdentityHashtable |
newAggregates |
protected IdentityHashtable |
newObjectsCloneToOriginal |
protected IdentityHashtable |
newObjectsOriginalToClone |
static int |
None |
protected IdentityHashtable |
objectsDeletedDuringCommit |
protected java.util.Map |
objectsLockedForClone
This collection will be used to store those objects that are currently locked
for the clone process.
|
protected java.util.Hashtable |
optimisticReadLockObjects
Kept reference of read lock objects
|
protected AbstractSession |
parent |
static int |
Partial |
protected IdentityHashtable |
pessimisticLockedObjects
use to track pessimistic locked objects
|
protected java.util.Hashtable |
readOnlyClasses
Read-only class can be used for reference data to avoid cloning when not required.
|
protected IdentityHashtable |
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 |
shouldCheckWriteLock
PERF: Cache the write-lock check to avoid cost of checking in every register/clone.
|
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 static boolean |
SmartMerge
Used for merging dependent values without use of WL SessionAccessor
|
static int |
THROW_ALL_CONFORM_EXCEPTIONS |
protected java.lang.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 IdentityHashtable |
unregisteredExistingObjects |
protected IdentityHashtable |
unregisteredNewObjects |
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 |
accessor, broker, commitManager, ejbqlPlaceHolderQueries, eventManager, exceptionHandler, externalTransactionController, identityMapAccessor, integrityChecker, isInProfile, lastDescriptorAccessed, logSessionString, name, numberOfActiveUnitsOfWork, platform, profiler, project, properties, queries, sessionLog, transactionMutex, wasJTSTransactionInternallyStarted| Constructor and Description |
|---|
UnitOfWorkImpl(AbstractSession parent)
INTERNAL:
Create and return a new unit of work with the sesson as its parent.
|
| Modifier and Type | Method and Description |
|---|---|
UnitOfWork |
acquireUnitOfWork()
PUBLIC:
Nested units of work are not supported in TopLink Essentials.
|
void |
addNewAggregate(java.lang.Object originalObject)
INTERNAL:
Register a new aggregate object with the unit of work.
|
void |
addObjectDeletedDuringCommit(java.lang.Object object,
ClassDescriptor descriptor)
INTERNAL:
Add object deleted during root commit of unit of work.
|
void |
addPessimisticLockedClone(java.lang.Object clone)
INTERNAL:
|
void |
addReadOnlyClass(java.lang.Class theClass)
PUBLIC:
Adds the given Java class to the receiver's set of read-only classes.
|
void |
addReadOnlyClasses(java.util.Vector classes)
PUBLIC:
Adds the classes in the given Vector to the existing set of read-only classes.
|
void |
addRemovedObject(java.lang.Object orignal)
INTERNAL:
Register that an object was removed in a nested unit of work.
|
void |
afterTransaction(boolean committed,
boolean isExternalTransaction)
INTERNAL:
Called after transaction is completed (committed or rolled back)
|
void |
assignSequenceNumber(java.lang.Object object)
ADVANCED:
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 |
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 explictly in a uow.
|
java.lang.Object |
buildOriginal(java.lang.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(IdentityHashtable allObjects,
UnitOfWorkChangeSet changeSet)
INTERNAL:
|
protected boolean |
canChangeReadOnlySet()
INTERNAL:
Checks whether the receiver has been used.
|
java.lang.Object |
checkExistence(java.lang.Object object)
INTERNAL:
Register the object and return the clone if it is existing otherwise return null if it is new.
|
boolean |
checkForUnregisteredExistingObject(java.lang.Object object)
INTERNAL:
|
protected java.lang.Object |
checkIfAlreadyRegistered(java.lang.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 used for comitting transactions:
all the changes sets will be dereferenced, and (optionally) the cache cleared.
|
protected java.lang.Object |
cloneAndRegisterNewObject(java.lang.Object original)
ADVANCED:
Register the new object with the unit of work.
|
java.lang.Object |
cloneAndRegisterObject(java.lang.Object original,
CacheKey cacheKey,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
Clone and register the object.
|
IdentityHashtable |
collectAndPrepareObjectsForCommit()
INTERNAL:
Prepare for commit.
|
IdentityHashtable |
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 Serialization
|
protected boolean |
commitInternallyStartedExternalTransaction()
PROTECTED:
Used in commit and commit-like methods to commit
internally started external transaction
|
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 database
|
protected void |
commitToDatabase(boolean commitTransaction)
INTERNAL:
CommitChanges To The Database from a calculated changeSet
|
protected void |
commitToDatabaseWithChangeSet(boolean commitTransaction)
INTERNAL:
Commit the changes to any objects to the parent.
|
protected void |
commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet,
boolean commitTransaction)
INTERNAL:
Commit pre-built changeSet to the database changest to the database.
|
void |
commitTransaction()
INTERNAL:
This is internal to the uow, transactions should not be used explictly in a uow.
|
protected void |
commitTransactionAfterWriteChanges()
INTERNAL:
After writeChanges() everything has been done except for committing
the transaction.
|
java.util.Vector |
copyReadOnlyClasses()
INTERNAL:
Copy the read only classes from the unit of work.
|
java.lang.Object |
deepMergeClone(java.lang.Object rmiClone)
PUBLIC:
Merge the attributes of the clone into the unit of work copy.
|
java.lang.Object |
deepRevertObject(java.lang.Object clone)
PUBLIC:
Revert the object's attributes from the parent.
|
void |
deepUnregisterObject(java.lang.Object clone)
ADVANCED:
Unregister the object with the unit of work.
|
void |
deleteAllObjects(java.util.Vector domainObjects)
PUBLIC:
Delete all of the objects and all of their privately owned parts in the database.
|
protected void |
discoverAllUnregisteredNewObjects()
INTERNAL:
Search for any objects in the parent that have not been registered.
|
void |
discoverUnregisteredNewObjects(java.lang.Object clone,
IdentityHashtable knownNewObjects,
IdentityHashtable unregisteredExistingObjects,
IdentityHashtable 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 refered after commit,
ensures that objects from the parent cache are not refered in the unit of work cache.
|
java.lang.Object |
executeCall(Call call,
AbstractRecord translationRow,
DatabaseQuery query)
INTERNAL:
Override From session.
|
void |
forceUpdateToVersionField(java.lang.Object lockObject,
boolean shouldModifyVersionField)
ADVANCED:
Set optmistic read lock on the object.
|
Accessor |
getAccessor()
INTERNAL:
The uow does not store a local accessor but shares its parents.
|
Accessor |
getAccessor(java.lang.Class domainClass)
INTERNAL:
The uow does not store a local accessor but shares its parents.
|
Accessor |
getAccessor(java.lang.String sessionName)
INTERNAL:
The uow does not store a local accessor but shares its parents.
|
UnitOfWork |
getActiveUnitOfWork()
PUBLIC:
Return the active unit of work for the current active external (JTS) transaction.
|
protected IdentityHashtable |
getAllClones()
INTERNAL:
This method is used to get a copy of the collection of all clones in the UnitOfWork
|
java.util.Vector |
getAllFromNewObjects(Expression selectionCriteria,
java.lang.Class theClass,
AbstractRecord translationRow,
InMemoryQueryIndirectionPolicy valueHolderPolicy)
INTERNAL:
Return any new objects matching the expression.
|
java.lang.Object |
getBackupClone(java.lang.Object clone)
INTERNAL:
Return the backup clone for the working clone.
|
java.lang.Object |
getBackupCloneForCommit(java.lang.Object clone)
INTERNAL:
Return the backup clone for the working clone.
|
IdentityHashtable |
getCloneMapping()
INTERNAL:
Return the clone mapping.
|
IdentityHashtable |
getCloneToOriginals()
INTERNAL:
Hashtable used to avoid garbage collection in weak caches.
|
CommitManager |
getCommitManager()
INTERNAL:
The commit manager is used to resolve referncial integrity on commits of multiple objects.
|
UnitOfWorkChangeSet |
getCurrentChanges()
ADVANCED:
This method Will Calculate the chages for the UnitOfWork.
|
java.util.Vector |
getDefaultReadOnlyClasses()
INTERNAL: Returns the set of read-only classes that gets assigned to each newly created UnitOfWork.
|
IdentityHashtable |
getDeletedObjects()
INTERNAL:
The deleted objects stores any objects removed during the unit of work.
|
ClassDescriptor |
getDescriptorForAlias(java.lang.String alias)
PUBLIC:
Return the descriptor for the alias.
|
java.util.Map |
getDescriptors()
PUBLIC:
Return all registered descriptors.
|
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.
|
IdentityHashtable |
getNewAggregates()
INTERNAL:
The hashtable stores any new aggregates that have been cloned.
|
IdentityHashtable |
getNewObjectsCloneToOriginal()
INTERNAL:
The new objects stores any objects newly created during the unit of work.
|
IdentityHashtable |
getNewObjectsOriginalToClone()
INTERNAL:
The new objects stores any objects newly created during the unit of work.
|
java.lang.Object |
getObjectFromNewObjects(java.lang.Class theClass,
java.util.Vector selectionKey)
INTERNAL:
Return any new object matching the expression.
|
java.lang.Object |
getObjectFromNewObjects(Expression selectionCriteria,
java.lang.Class theClass,
AbstractRecord translationRow,
InMemoryQueryIndirectionPolicy valueHolderPolicy)
INTERNAL:
Return any new object matching the expression.
|
IdentityHashtable |
getObjectsDeletedDuringCommit()
INTERNAL:
Returns all the objects which are deleted during root commit of unit of work.
|
java.util.Hashtable |
getOptimisticReadLockObjects()
INTERNAL:
Return optimistic read lock objects
|
java.lang.Object |
getOriginalVersionOfNewObject(java.lang.Object workingClone)
INTERNAL:
Return the original version of the new object (working clone).
|
java.lang.Object |
getOriginalVersionOfObject(java.lang.Object workingClone)
ADVANCED:
Return the original version of the object(clone) from the parent's identity map.
|
java.lang.Object |
getOriginalVersionOfObjectOrNull(java.lang.Object workingClone)
ADVANCED:
Return the original version of the object(clone) from the parent's identity map.
|
AbstractSession |
getParent()
PUBLIC:
Return the parent.
|
AbstractSession |
getParentIdentityMapSession(DatabaseQuery query,
boolean canReturnSelf,
boolean terminalOnly)
INTERNAL:
Gets the next link in the chain of sessions followed by a query's check
early return, the chain of sessions with identity maps all the way up to
the root session.
|
IdentityHashtable |
getPessimisticLockedObjects()
INTERNAL:
|
Platform |
getPlatform(java.lang.Class domainClass)
INTERNAL:
Return the platform for a particular class.
|
DatabaseQuery |
getQuery(java.lang.String name)
PUBLIC:
Return the query from the session pre-defined queries with the given name.
|
DatabaseQuery |
getQuery(java.lang.String name,
java.util.Vector arguments)
PUBLIC:
Return the query from the session pre-defined queries with the given name.
|
java.util.Hashtable |
getReadOnlyClasses()
INTERNAL:
Returns the set of read-only classes for the receiver.
|
protected IdentityHashtable |
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 TopLink's other sessions types
(ie not DatabaseSession)
|
java.lang.String |
getSessionTypeString()
INTERNAL:
Returns the type of session, its class.
|
int |
getShouldThrowConformExceptions()
INTERNAL:
Return whether to throw exceptions on conforming queries
|
int |
getState()
INTERNAL:
Find out what the lifecycle state of this UoW is in.
|
java.lang.Object |
getTransaction()
INTERNAL:
PERF: Return the associated external transaction.
|
UnitOfWorkChangeSet |
getUnitOfWorkChangeSet()
ADVANCED:
Returns the currentChangeSet from the UnitOfWork.
|
IdentityHashtable |
getUnregisteredExistingObjects()
INTERNAL:
Used to lazy Initialize the unregistered existing Objects collection.
|
protected IdentityHashtable |
getUnregisteredNewObjects()
INTERNAL:
This is used to store unregistred 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 refered after commit,
ensures that objects from the parent cache are not refered in the unit of work cache.
|
java.lang.Object |
getWorkingCopyFromUnitOfWorkIdentityMap(java.lang.Object object,
java.util.Vector primaryKey)
INTERNAL:
Return the registered working copy from the unit of work identity map.
|
boolean |
hasChanges()
ADVANCED:
The Unit of work is capable of preprocessing to determine if any on the clone have been changed.
|
protected boolean |
hasCloneMapping() |
protected boolean |
hasCloneToOriginals() |
protected boolean |
hasDeferredModifyAllQueries() |
protected boolean |
hasDeletedObjects() |
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 |
hasObjectsDeletedDuringCommit() |
protected boolean |
hasRemovedObjects() |
void |
initializeIdentityMapAccessor()
INTERNAL:
Set up the IdentityMapManager.
|
java.lang.Object |
internalExecuteQuery(DatabaseQuery query,
AbstractRecord databaseRow)
INTERNAL:
Return the results from exeucting the database query.
|
java.lang.Object |
internalRegisterObject(java.lang.Object object,
ClassDescriptor descriptor)
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 suceeded 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(java.lang.Class theClass,
ClassDescriptor descriptor)
PUBLIC:
Checks to see if the specified class or descriptor is read-only or not in this UnitOfWork.
|
boolean |
isCloneNewObject(java.lang.Object clone)
INTERNAL:
Check if the object is already registered.
|
boolean |
isCommitPending()
INTERNAL:
Return if the unit of work is waiting to be committed or in the process of being committed.
|
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 |
isObjectDeleted(java.lang.Object object)
INTERNAL:
Return if the object has been deleted in this unit of work.
|
boolean |
isObjectNew(java.lang.Object clone)
INTERNAL:
This method is used to determine if the clone is a new Object in the UnitOfWork
|
boolean |
isObjectRegistered(java.lang.Object clone)
INTERNAL:
Return whether the clone object is already registered.
|
boolean |
isOriginalNewObject(java.lang.Object original)
INTERNAL:
Return whether the original object is new.
|
boolean |
isPessimisticLocked(java.lang.Object clone)
INTERNAL:
|
static boolean |
isSmartMerge()
INTERNAL:
Return the status of smart merge
|
protected 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 |
isSynchronized()
INTERNAL:
Return if this session is a synchronized unit of work.
|
boolean |
isUnitOfWork()
PUBLIC:
Return if this session is a unit of work.
|
protected void |
mergeChangesIntoParent()
INTERNAL: Merge the changes to all objects to the parent.
|
java.lang.Object |
mergeClone(java.lang.Object rmiClone)
PUBLIC:
Merge the attributes of the clone into the unit of work copy.
|
java.lang.Object |
mergeClone(java.lang.Object rmiClone,
int cascadeDepth)
INTERNAL:
Merge the attributes of the clone into the unit of work copy.
|
void |
mergeClonesAfterCompletion()
INTERNAL:
for synchronized units of work, merge changes into parent
|
java.lang.Object |
mergeCloneWithReferences(java.lang.Object rmiClone)
PUBLIC:
Merge the attributes of the clone into the unit of work copy.
|
java.lang.Object |
mergeCloneWithReferences(java.lang.Object rmiClone,
int cascadePolicy)
PUBLIC:
Merge the attributes of the clone into the unit of work copy.
|
java.lang.Object |
mergeCloneWithReferences(java.lang.Object rmiClone,
int cascadePolicy,
boolean forceCascade)
INTERNAL:
Merge the attributes of the clone into the unit of work copy.
|
java.lang.Object |
newInstance(java.lang.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 refered after commit,
ensures that objects from the parent cache are not refered 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 refered after commit,
ensures that objects from the parent cache are not refered in the unit of work cache.
|
void |
performRemove(java.lang.Object toBeDeleted,
IdentityHashtable visitedObjects)
INTERNAL:
This method will perform a delete operation on the provided objects pre-determing
the objects that will be deleted by a commit of the UnitOfWork including privately
owned objects.
|
protected void |
populateAndRegisterObject(java.lang.Object original,
java.lang.Object workingClone,
java.util.Vector primaryKey,
ClassDescriptor descriptor,
java.lang.Object writeLockValue,
long readTime,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
This method is called from clone and register.
|
protected void |
postMergeChanges()
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 merged
|
void |
printRegisteredObjects()
PUBLIC:
Print the objects in the unit of work.
|
java.lang.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
|
java.util.Vector |
registerAllObjects(java.util.Collection domainObjects)
PUBLIC:
Register the objects with the unit of work.
|
java.util.Vector |
registerAllObjects(java.util.Vector domainObjects)
PUBLIC:
Register the objects with the unit of work.
|
java.lang.Object |
registerExistingObject(java.lang.Object existingObject)
ADVANCED:
Register the existing object with the unit of work.
|
protected java.lang.Object |
registerExistingObject(java.lang.Object objectToRegister,
ClassDescriptor descriptor,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
Register the existing object with the unit of work.
|
java.lang.Object |
registerExistingObject(java.lang.Object existingObject,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
Register the existing object with the unit of work.
|
java.lang.Object |
registerNewObject(java.lang.Object newObject)
ADVANCED:
Register the new object with the unit of work.
|
protected java.lang.Object |
registerNewObject(java.lang.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(java.lang.Object clone,
java.lang.Object original)
INTERNAL:
Register the working copy of a new object and its original.
|
void |
registerNewObjectForPersist(java.lang.Object newObject,
IdentityHashtable visitedObjects)
INTERNAL:
Register the new object with the unit of work.
|
protected void |
registerNewObjectInIdentityMap(java.lang.Object clone,
java.lang.Object original)
INTERNAL:
Add the new object to the cache if set to.
|
protected void |
registerNotRegisteredNewObjectForPersist(java.lang.Object newObject,
ClassDescriptor descriptor)
INTERNAL:
Called only by registerNewObjectForPersist method,
and only if newObject is not already registered.
|
java.lang.Object |
registerObject(java.lang.Object object)
PUBLIC:
Register the object with the unit of work.
|
protected java.lang.Object |
registerObject(java.lang.Object object,
ClassDescriptor descriptor)
INTERNAL:
Allows for calling method to provide the descriptor information for this
object.
|
void |
registerWithTransactionIfRequired()
INTERNAL:
Register this UnitOfWork against an external transaction controller
|
void |
release()
PUBLIC:
Release the unit of work.
|
void |
removeAllReadOnlyClasses()
PUBLIC:
Empties the set of read-only classes.
|
void |
removeForceUpdateToVersionField(java.lang.Object lockObject)
ADVANCED:
Remove optimistic read lock from the object
See forceUpdateToVersionField(Object)
|
void |
removeReadOnlyClass(java.lang.Class theClass)
PUBLIC:
Removes a Class from the receiver's set of read-only classes.
|
protected void |
resetAllCloneCollection()
INTERNAL:
Used in the resume to reset the all clones collection
|
void |
revertAndResume()
PUBLIC:
Revert all changes made to any registered object.
|
java.lang.Object |
revertObject(java.lang.Object clone)
PUBLIC:
Revert the object's attributes from the parent.
|
java.lang.Object |
revertObject(java.lang.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 explictly in a uow.
|
protected void |
rollbackTransaction(boolean intendedToCommitTransaction)
INTERNAL:
rollbackTransaction() with a twist for external transactions.
|
IdentityHashtable |
scanForConformingInstances(Expression selectionCriteria,
java.lang.Class referenceClass,
AbstractRecord arguments,
ObjectLevelReadQuery query)
INTERNAL:
Scans the UnitOfWork identity map for conforming instances.
|
protected void |
setAllClonesCollection(IdentityHashtable objects)
INTERNAL:
Used to set the collections of all objects in the UnitOfWork.
|
protected void |
setCloneMapping(IdentityHashtable cloneMapping)
INTERNAL:
Set the clone mapping.
|
void |
setDead()
INTERNAL:
set UoW lifecycle state variable to DEATH
|
protected void |
setDeletedObjects(IdentityHashtable 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(IdentityHashtable newObjects)
INTERNAL:
The new objects stores any objects newly created during the unit of work.
|
protected void |
setNewObjectsOriginalToClone(IdentityHashtable newObjects)
INTERNAL:
The new objects stores any objects newly created during the unit of work.
|
void |
setObjectsDeletedDuringCommit(IdentityHashtable 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_MERGE
|
void |
setReadOnlyClasses(java.util.Vector classes)
INTERNAL:
Gives a new set of read-only classes to the receiver.
|
protected void |
setRemovedObjects(IdentityHashtable 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 control
|
void |
setShouldCascadeCloneToJoinedRelationship(boolean shouldCascadeCloneToJoinedRelationship)
INTERNAL:
True if the value holder for the joined attribute should be triggered.
|
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 three levels:
DO_NOT_THROW_CONFORM_EXCEPTIONS = 0;
THROW_ALL_CONFORM_EXCEPTIONS = 1;
|
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(java.lang.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(IdentityHashtable newUnregisteredExistingObjects)
INTERNAL:
Used to set the unregistered existing objects vector used when validation has been turned off.
|
protected void |
setUnregisteredNewObjects(IdentityHashtable 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 refered after commit,
ensures that objects from the parent cache are not refered 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.
|
java.lang.Object |
shallowMergeClone(java.lang.Object rmiClone)
PUBLIC:
Merge the attributes of the clone into the unit of work copy.
|
java.lang.Object |
shallowRevertObject(java.lang.Object clone)
PUBLIC:
Revert the object's attributes from the parent.
|
void |
shallowUnregisterObject(java.lang.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 methor should be called by release method.
|
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 refered 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 refered 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 control
|
void |
storeDeferredModifyAllQuery(DatabaseQuery query,
AbstractRecord translationRow)
INTERNAL:
Store the deferred UpdateAllQuery's from the UoW in the list.
|
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(java.lang.Object object)
INTERNAL:
THis method is used to transition an object from the deleted objects list
to be simply be register.
|
void |
unregisterObject(java.lang.Object clone)
PUBLIC:
Unregister the object with the unit of work.
|
void |
unregisterObject(java.lang.Object clone,
int cascadeDepth)
INTERNAL:
Unregister the object with the unit of work.
|
void |
updateChangeTrackersIfRequired(java.lang.Object objectToWrite,
ObjectChangeSet changeSetToWrite,
UnitOfWorkImpl uow,
ClassDescriptor descriptor)
INTERNAL:
This method is used internally to update the tracked objects if required
|
void |
validateObjectSpace()
ADVANCED:
This can be used to help debugging an object-space corruption.
|
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.
|
acquireNonSynchronizedUnitOfWork, addAlias, addEjbqlPlaceHolderQuery, addQuery, addQuery, basicBeginTransaction, basicCommitTransaction, basicRollbackTransaction, beginExternalTransaction, clearIntegrityChecker, clearLastDescriptorAccessed, clearProfile, clone, commitExternalTransaction, compareObjects, compareObjectsDontMatch, config, containsQuery, copyObject, copyObject, deleteAllObjects, deleteObject, doesObjectExist, dontLogMessages, endOperationProfile, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, fine, finer, finest, getActiveSession, getAliasDescriptors, getAllQueries, getBroker, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getDatasourceLogin, getDatasourcePlatform, getDescriptor, getDescriptor, getEjbqlPlaceHolderQueries, getEventManager, getExceptionHandler, getExceptionHandlerClass, getExternalTransactionController, getIdentityMapAccessor, getIdentityMapAccessorInstance, getIntegrityChecker, getLog, getLogin, getLogLevel, getLogLevel, getLogSessionString, getName, getNextQueryId, getNextSequenceNumberValue, getNumberOfActiveUnitsOfWork, getParentIdentityMapSession, getPlatform, getProfiler, getProject, getProperties, getProperty, getQueries, getRootSession, getSessionForClass, getSessionLog, getTransactionMutex, handleException, handleSevere, hasBroker, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, hasProperties, incrementProfile, info, insertObject, isBroker, isClassReadOnly, isClientSession, isConnected, isDatabaseSession, isDistributedSession, isInBroker, isInProfile, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, keyFromObject, keyFromObject, log, log, log, log, log, log, log, log, log, log, logMessage, logThrowable, prepareDatabaseQuery, processEJBQLQueries, processEJBQLQueries, readAllObjects, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, readObject, refreshAndLockObject, refreshAndLockObject, refreshObject, releaseUnitOfWork, removeProperty, removeQuery, removeQuery, rollbackExternalTransaction, setAccessor, setBroker, setCommitManager, setDatasourceLogin, setEventManager, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setIsInProfile, setLog, setLogin, setLogin, setLogLevel, setName, setNumberOfActiveUnitsOfWork, setProfiler, setProject, setProperties, setProperty, setQueries, setSessionLog, setTransactionMutex, setWasJTSTransactionInternallyStarted, severe, shouldLog, shouldLogMessages, startOperationProfile, toString, unwrapObject, updateObject, updateProfile, validateQuery, verifyDelete, warning, wasJTSTransactionInternallyStarted, wrapObject, writeAllObjects, writeAllObjectsWithChangeSet, writeObjectequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdeleteAllObjects, deleteObject, isClassReadOnly, refreshAndLockObject, refreshAndLockObjectaddEjbqlPlaceHolderQuery, addQuery, clearIntegrityChecker, clearProfile, containsQuery, copyObject, copyObject, doesObjectExist, dontLogMessages, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, getActiveSession, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getDatasourceLogin, getDatasourcePlatform, getDescriptor, getDescriptor, getEjbqlPlaceHolderQueries, getEventManager, getExceptionHandler, getExternalTransactionController, getIdentityMapAccessor, getIntegrityChecker, getLog, getLogin, getLogLevel, getLogLevel, getName, getNextSequenceNumberValue, getPlatform, getProfiler, getProject, getProperties, getProperty, getQueries, getSessionLog, handleException, handleSevere, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, isClientSession, isConnected, isDatabaseSession, isDistributedSession, isInProfile, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, keyFromObject, log, log, logMessage, logThrowable, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, refreshObject, removeProperty, removeQuery, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setLog, setLogLevel, setName, setProfiler, setProperty, setSessionLog, shouldLog, shouldLogMessagesprotected transient IdentityHashtable cloneToOriginals
protected transient AbstractSession parent
protected IdentityHashtable cloneMapping
protected IdentityHashtable newObjectsCloneToOriginal
protected IdentityHashtable newObjectsOriginalToClone
protected IdentityHashtable deletedObjects
protected IdentityHashtable allClones
protected IdentityHashtable objectsDeletedDuringCommit
protected IdentityHashtable removedObjects
protected IdentityHashtable unregisteredNewObjects
protected IdentityHashtable unregisteredExistingObjects
protected IdentityHashtable newAggregates
protected UnitOfWorkChangeSet unitOfWorkChangeSet
protected IdentityHashtable pessimisticLockedObjects
protected MergeManager lastUsedMergeManager
protected java.util.Hashtable readOnlyClasses
protected boolean wasTransactionBegunPrematurely
protected boolean shouldNewObjectsBeCached
protected boolean shouldPerformDeletesFirst
protected int shouldThrowConformExceptions
protected int validationLevel
public static final int None
public static final int Partial
public static final int Full
protected boolean isSynchronized
protected int lifecycle
public static final int Birth
public static final int CommitPending
public static final int CommitTransactionPending
public static final int WriteChangesFailed
public static final int MergePending
public static final int Death
public static final int AfterExternalTransactionRolledBack
public static final int DO_NOT_THROW_CONFORM_EXCEPTIONS
public static final int THROW_ALL_CONFORM_EXCEPTIONS
public static final java.lang.String LOCK_QUERIES_PROPERTY
protected static boolean SmartMerge
protected java.util.Hashtable optimisticReadLockObjects
protected java.util.List modifyAllQueries
protected java.util.List deferredModifyAllQueries
protected int cloneDepth
protected java.util.Map objectsLockedForClone
protected java.lang.Object transaction
protected boolean shouldCheckWriteLock
protected boolean resumeOnTransactionCompletion
protected boolean wasNonObjectLevelModifyQueryExecuted
protected boolean shouldCascadeCloneToJoinedRelationship
public UnitOfWorkImpl(AbstractSession parent)
public UnitOfWork acquireUnitOfWork()
acquireUnitOfWork in interface SessionacquireUnitOfWork in class AbstractSessionUnitOfWorkpublic void addNewAggregate(java.lang.Object originalObject)
public void addObjectDeletedDuringCommit(java.lang.Object object,
ClassDescriptor descriptor)
public void addReadOnlyClass(java.lang.Class theClass)
throws ValidationException
addReadOnlyClass in interface UnitOfWorkValidationExceptionpublic void addReadOnlyClasses(java.util.Vector classes)
addReadOnlyClasses in interface UnitOfWorkpublic void addRemovedObject(java.lang.Object orignal)
public void assignSequenceNumber(java.lang.Object object)
throws DatabaseException
assignSequenceNumber in interface UnitOfWorkDatabaseExceptionpublic void assignSequenceNumbers()
throws DatabaseException
assignSequenceNumbers in interface UnitOfWorkDatabaseExceptionpublic void beginEarlyTransaction()
throws DatabaseException
beginEarlyTransaction in interface UnitOfWorkDatabaseExceptioncommit(),
release()public void beginTransaction()
throws DatabaseException
beginTransaction in class AbstractSessionDatabaseException - if the database connection is lost or the begin is rejected.AbstractSession.isInTransaction()public java.lang.Object buildOriginal(java.lang.Object workingClone)
public UnitOfWorkChangeSet calculateChanges(IdentityHashtable allObjects, UnitOfWorkChangeSet changeSet)
This Method is designed to calculate the changes for all objects within the PendingObjects.
protected boolean canChangeReadOnlySet()
public boolean checkForUnregisteredExistingObject(java.lang.Object object)
public java.lang.Object checkExistence(java.lang.Object object)
protected java.lang.Object checkIfAlreadyRegistered(java.lang.Object object,
ClassDescriptor descriptor)
protected java.lang.Object cloneAndRegisterNewObject(java.lang.Object original)
registerObject(Object)public java.lang.Object cloneAndRegisterObject(java.lang.Object original,
CacheKey cacheKey,
JoinedAttributeManager joinedAttributeManager)
public IdentityHashtable collectAndPrepareObjectsForCommit()
public IdentityHashtable collectAndPrepareObjectsForNestedMerge()
public void commit()
throws DatabaseException,
OptimisticLockException
commit in interface UnitOfWorkDatabaseExceptionOptimisticLockExceptioncommitAndResumeOnFailure(),
commitAndResume(),
release()public void commitAndResume()
throws DatabaseException,
OptimisticLockException
commitAndResume in interface UnitOfWorkDatabaseExceptionOptimisticLockExceptioncommitAndResumeOnFailure(),
commit(),
release()public void commitAndResumeWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet) throws DatabaseException, OptimisticLockException
public void commitAndResumeOnFailure()
throws DatabaseException,
OptimisticLockException
commitAndResumeOnFailure in interface UnitOfWorkDatabaseExceptionOptimisticLockExceptioncommit(),
release()protected void commitAfterWriteChanges()
a.k.a finalizeCommit()
protected void commitAndResumeAfterWriteChanges()
a.k.a finalizeCommit()
protected boolean commitInternallyStartedExternalTransaction()
public void commitRootUnitOfWork()
throws DatabaseException,
OptimisticLockException
public void commitRootUnitOfWorkWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet) throws DatabaseException, OptimisticLockException
protected void commitToDatabase(boolean commitTransaction)
commitTransaction - false if called by writeChanges as intent is
not to finalize the transaction.protected void commitToDatabaseWithChangeSet(boolean commitTransaction)
throws DatabaseException,
OptimisticLockException
commitTransaction - false if called by writeChanges as intent is
not to finalize the transaction.DatabaseExceptionOptimisticLockExceptionprotected void commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet, boolean commitTransaction) throws DatabaseException, OptimisticLockException
public void commitTransaction()
throws DatabaseException
commitTransaction in class AbstractSessionDatabaseException - most databases validate changes as they are done,
normally errors do not occur on commit unless the disk fails or the connection is lost.protected void commitTransactionAfterWriteChanges()
public java.util.Vector copyReadOnlyClasses()
copyReadOnlyClasses in class AbstractSessionpublic java.lang.Object deepMergeClone(java.lang.Object rmiClone)
deepMergeClone in interface UnitOfWorkmergeClone(Object),
shallowMergeClone(Object)public java.lang.Object deepRevertObject(java.lang.Object clone)
deepRevertObject in interface UnitOfWorkrevertObject(Object),
shallowRevertObject(Object)public void deepUnregisterObject(java.lang.Object clone)
deepUnregisterObject in interface UnitOfWorkpublic void deleteAllObjects(java.util.Vector domainObjects)
deleteAllObjects in interface UnitOfWorkdeleteAllObjects in class AbstractSessionprotected void discoverAllUnregisteredNewObjects()
public void discoverUnregisteredNewObjects(java.lang.Object clone,
IdentityHashtable knownNewObjects,
IdentityHashtable unregisteredExistingObjects,
IdentityHashtable visitedObjects)
public void dontPerformValidation()
dontPerformValidation in interface UnitOfWorkpublic java.lang.Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException
executeCall in class AbstractSessionDatabaseExceptionpublic void forceUpdateToVersionField(java.lang.Object lockObject,
boolean shouldModifyVersionField)
forceUpdateToVersionField in interface UnitOfWorkpublic Accessor getAccessor()
getAccessor in class AbstractSessionpublic CommitManager getCommitManager()
getCommitManager in class AbstractSessionpublic Accessor getAccessor(java.lang.Class domainClass)
getAccessor in class AbstractSessionpublic Accessor getAccessor(java.lang.String sessionName)
getAccessor in class AbstractSessionpublic UnitOfWork getActiveUnitOfWork()
getActiveUnitOfWork in interface SessiongetActiveUnitOfWork in class AbstractSessionprotected IdentityHashtable getAllClones()
public java.util.Vector getAllFromNewObjects(Expression selectionCriteria, java.lang.Class theClass, AbstractRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy)
public java.lang.Object getBackupClone(java.lang.Object clone)
throws QueryException
QueryExceptionpublic java.lang.Object getBackupCloneForCommit(java.lang.Object clone)
public UnitOfWorkChangeSet getCurrentChanges()
getCurrentChanges in interface UnitOfWorkpublic AbstractSession getParentIdentityMapSession(DatabaseQuery query, boolean canReturnSelf, boolean terminalOnly)
Used for session broker which delegates to registered sessions, or UnitOfWork which checks parent identity map also.
getParentIdentityMapSession in class AbstractSessioncanReturnSelf - true when method calls itself. If the path
starting at this 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 session we will execute the call on, not
the next step towards it.public AbstractSession getExecutionSession(DatabaseQuery query)
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.
getExecutionSession in class AbstractSessionquery - may store session name or reference class for brokers casepublic IdentityHashtable getCloneMapping()
protected boolean hasCloneMapping()
public IdentityHashtable getCloneToOriginals()
protected boolean hasCloneToOriginals()
public boolean hasNewObjects()
public java.util.Vector getDefaultReadOnlyClasses()
getDefaultReadOnlyClasses in class AbstractSessionProject.setDefaultReadOnlyClasses(Vector)public IdentityHashtable getDeletedObjects()
protected boolean hasDeletedObjects()
public ClassDescriptor getDescriptorForAlias(java.lang.String alias)
getDescriptorForAlias in interface SessiongetDescriptorForAlias in class AbstractSessionpublic java.util.Map getDescriptors()
getDescriptors in interface SessiongetDescriptors in class AbstractSessionpublic int getLifecycle()
public MergeManager getMergeManager()
public IdentityHashtable getNewAggregates()
public IdentityHashtable getNewObjectsCloneToOriginal()
public IdentityHashtable getNewObjectsOriginalToClone()
public Sequencing getSequencing()
getSequencing in class AbstractSessionpublic ServerPlatform getServerPlatform()
getServerPlatform in class AbstractSessionpublic java.lang.String getSessionTypeString()
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.
getSessionTypeString in class AbstractSessionpublic void afterTransaction(boolean committed,
boolean isExternalTransaction)
afterTransaction in class AbstractSessionpublic java.lang.Object getObjectFromNewObjects(java.lang.Class theClass,
java.util.Vector selectionKey)
public java.lang.Object getObjectFromNewObjects(Expression selectionCriteria, java.lang.Class theClass, AbstractRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy)
public IdentityHashtable getObjectsDeletedDuringCommit()
protected boolean hasObjectsDeletedDuringCommit()
public java.util.Hashtable getOptimisticReadLockObjects()
public java.lang.Object getOriginalVersionOfNewObject(java.lang.Object workingClone)
public java.lang.Object getOriginalVersionOfObject(java.lang.Object workingClone)
getOriginalVersionOfObject in interface UnitOfWorkpublic java.lang.Object getOriginalVersionOfObjectOrNull(java.lang.Object workingClone)
public AbstractSession getParent()
getParent in interface UnitOfWorkpublic Platform getPlatform(java.lang.Class domainClass)
getPlatform in class AbstractSessionpublic int getShouldThrowConformExceptions()
public DatabaseQuery getQuery(java.lang.String name, java.util.Vector arguments)
getQuery in interface SessiongetQuery in class AbstractSessionAbstractSession.getQuery(String)public DatabaseQuery getQuery(java.lang.String name)
getQuery in interface SessiongetQuery in class AbstractSessionpublic java.util.Hashtable getReadOnlyClasses()
setReadOnlyClasses(Vector)protected IdentityHashtable getRemovedObjects()
protected boolean hasRemovedObjects()
protected boolean hasModifyAllQueries()
protected boolean hasDeferredModifyAllQueries()
public int getState()
public java.lang.Object getTransaction()
public void setTransaction(java.lang.Object transaction)
public UnitOfWorkChangeSet getUnitOfWorkChangeSet()
getUnitOfWorkChangeSet in interface UnitOfWorkpublic IdentityHashtable getUnregisteredExistingObjects()
protected IdentityHashtable getUnregisteredNewObjects()
public int getValidationLevel()
getValidationLevel in interface UnitOfWorkpublic boolean hasChanges()
hasChanges in interface UnitOfWorkprotected boolean hasModifications()
Note if a transaction was begun prematurely it still needs to be committed.
public void initializeIdentityMapAccessor()
initializeIdentityMapAccessor in class AbstractSessionpublic java.lang.Object internalExecuteQuery(DatabaseQuery query, AbstractRecord databaseRow) throws DatabaseException, QueryException
internalExecuteQuery in class AbstractSessionDatabaseExceptionQueryExceptionpublic java.lang.Object internalRegisterObject(java.lang.Object object,
ClassDescriptor descriptor)
public boolean isActive()
isActive in interface UnitOfWorkpublic boolean isClassReadOnly(java.lang.Class theClass,
ClassDescriptor descriptor)
isClassReadOnly in class AbstractSessionpublic boolean isCloneNewObject(java.lang.Object clone)
public boolean isCommitPending()
public boolean isDead()
public boolean isInTransaction()
isInTransaction in class AbstractSessionpublic boolean isMergePending()
public boolean isAfterWriteChangesButBeforeCommit()
protected boolean isAfterWriteChangesFailed()
public boolean isNestedUnitOfWork()
isNestedUnitOfWork in interface UnitOfWorkpublic boolean isObjectDeleted(java.lang.Object object)
public boolean isObjectNew(java.lang.Object clone)
public boolean isObjectRegistered(java.lang.Object clone)
public boolean isOriginalNewObject(java.lang.Object original)
public static boolean isSmartMerge()
public void issueSQLbeforeCompletion()
public void issueSQLbeforeCompletion(boolean commitTransaction)
protected void issueModifyAllQueryList()
public boolean isSynchronized()
public boolean isUnitOfWork()
isUnitOfWork in interface SessionisUnitOfWork in class AbstractSessionprotected void mergeChangesIntoParent()
public java.lang.Object mergeClone(java.lang.Object rmiClone)
mergeClone in interface UnitOfWorkshallowMergeClone(Object),
deepMergeClone(Object)public java.lang.Object mergeClone(java.lang.Object rmiClone,
int cascadeDepth)
public void mergeClonesAfterCompletion()
public java.lang.Object mergeCloneWithReferences(java.lang.Object rmiClone)
mergeCloneWithReferences in interface UnitOfWorkshallowMergeClone(Object),
deepMergeClone(Object)public java.lang.Object mergeCloneWithReferences(java.lang.Object rmiClone,
int cascadePolicy)
shallowMergeClone(Object),
deepMergeClone(Object)public java.lang.Object mergeCloneWithReferences(java.lang.Object rmiClone,
int cascadePolicy,
boolean forceCascade)
shallowMergeClone(Object),
deepMergeClone(Object)public java.lang.Object newInstance(java.lang.Class theClass)
newInstance in interface UnitOfWorkpublic void performRemove(java.lang.Object toBeDeleted,
IdentityHashtable visitedObjects)
public void performFullValidation()
performFullValidation in interface UnitOfWorkpublic void performPartialValidation()
performPartialValidation in interface UnitOfWorkprotected void populateAndRegisterObject(java.lang.Object original,
java.lang.Object workingClone,
java.util.Vector primaryKey,
ClassDescriptor descriptor,
java.lang.Object writeLockValue,
long readTime,
JoinedAttributeManager joinedAttributeManager)
protected void postMergeChanges()
protected void preMergeChanges()
public void printRegisteredObjects()
printRegisteredObjects in interface UnitOfWorkpublic java.lang.Object processDeleteObjectQuery(DeleteObjectQuery deleteQuery)
protected void basicPrintRegisteredObjects()
public java.util.Vector registerAllObjects(java.util.Collection domainObjects)
registerAllObjects in interface UnitOfWorkpublic java.util.Vector registerAllObjects(java.util.Vector domainObjects)
throws DatabaseException,
OptimisticLockException
registerAllObjects in interface UnitOfWorkDatabaseExceptionOptimisticLockExceptionpublic java.lang.Object registerExistingObject(java.lang.Object existingObject,
JoinedAttributeManager joinedAttributeManager)
public java.lang.Object registerExistingObject(java.lang.Object existingObject)
registerExistingObject in interface UnitOfWorkprotected java.lang.Object registerExistingObject(java.lang.Object objectToRegister,
ClassDescriptor descriptor,
JoinedAttributeManager joinedAttributeManager)
public java.lang.Object registerNewObject(java.lang.Object newObject)
registerNewObject in interface UnitOfWorkregisterObject(Object)protected java.lang.Object registerNewObject(java.lang.Object implementation,
ClassDescriptor descriptor)
registerObject(Object)public void registerNewObjectForPersist(java.lang.Object newObject,
IdentityHashtable visitedObjects)
registerObject(Object)protected void registerNotRegisteredNewObjectForPersist(java.lang.Object newObject,
ClassDescriptor descriptor)
protected void registerNewObjectClone(java.lang.Object clone,
java.lang.Object original)
protected void registerNewObjectInIdentityMap(java.lang.Object clone,
java.lang.Object original)
public java.lang.Object registerObject(java.lang.Object object)
registerObject in interface UnitOfWorkprotected java.lang.Object registerObject(java.lang.Object object,
ClassDescriptor descriptor)
public void registerWithTransactionIfRequired()
public void release()
release in interface Sessionrelease in interface UnitOfWorkrelease in class AbstractSessioncommit()public void removeAllReadOnlyClasses()
throws ValidationException
removeAllReadOnlyClasses in interface UnitOfWorkValidationExceptionpublic void removeForceUpdateToVersionField(java.lang.Object lockObject)
removeForceUpdateToVersionField in interface UnitOfWorkpublic void removeReadOnlyClass(java.lang.Class theClass)
throws ValidationException
removeReadOnlyClass in interface UnitOfWorkValidationExceptionprotected void resetAllCloneCollection()
public void revertAndResume()
revertAndResume in interface UnitOfWorkcommitAndResume(),
release()public java.lang.Object revertObject(java.lang.Object clone)
revertObject in interface UnitOfWorkshallowRevertObject(Object),
deepRevertObject(Object)public java.lang.Object revertObject(java.lang.Object clone,
int cascadeDepth)
public void rollbackTransaction()
throws DatabaseException
rollbackTransaction in class AbstractSessionDatabaseException - if the database connection is lost or the rollback fails.protected void rollbackTransaction(boolean intendedToCommitTransaction)
throws DatabaseException
writeChanges() is called outside the JTA beforeCompletion(), so the accompanying exception won't propogate 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.
intendedToCommitTransaction - whether we were inside a commit or just trying to
write out changes early.DatabaseExceptionpublic IdentityHashtable scanForConformingInstances(Expression selectionCriteria, java.lang.Class referenceClass, AbstractRecord arguments, ObjectLevelReadQuery query)
Later this method can be made recursive to check all parent units of work also.
selectionCriteria - must be cloned and specially prepared for conformingprotected void setAllClonesCollection(IdentityHashtable objects)
newUnregisteredExistingObjects - oracle.toplink.essentials.internal.helper.IdentityHashtableprotected void setCloneMapping(IdentityHashtable cloneMapping)
public void setDead()
protected void setDeletedObjects(IdentityHashtable deletedObjects)
protected void setLifecycle(int lifecycle)
public void setMergeManager(MergeManager mergeManager)
protected void setNewObjectsCloneToOriginal(IdentityHashtable newObjects)
protected void setNewObjectsOriginalToClone(IdentityHashtable newObjects)
public void setObjectsDeletedDuringCommit(IdentityHashtable deletedObjects)
public void setParent(AbstractSession parent)
public void setPendingMerge()
public void setReadOnlyClasses(java.util.Vector classes)
protected void setRemovedObjects(IdentityHashtable removedObjects)
public void setResumeUnitOfWorkOnTransactionCompletion(boolean resumeUnitOfWork)
public void setShouldCascadeCloneToJoinedRelationship(boolean shouldCascadeCloneToJoinedRelationship)
public void setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached)
setShouldNewObjectsBeCached in interface UnitOfWorkpublic void setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst)
setShouldPerformDeletesFirst in interface UnitOfWorkpublic void setShouldThrowConformExceptions(int shouldThrowExceptions)
setShouldThrowConformExceptions in interface UnitOfWorkpublic static void setSmartMerge(boolean option)
public void setSynchronized(boolean synched)
public void setUnitOfWorkChangeSet(UnitOfWorkChangeSet unitOfWorkChangeSet)
protected void setUnregisteredExistingObjects(IdentityHashtable newUnregisteredExistingObjects)
newUnregisteredExistingObjects - oracle.toplink.essentials.internal.helper.IdentityHashtableprotected void setUnregisteredNewObjects(IdentityHashtable newObjects)
public void setValidationLevel(int validationLevel)
setValidationLevel in interface UnitOfWorkpublic void setWasTransactionBegunPrematurely(boolean wasTransactionBegunPrematurely)
public java.lang.Object shallowMergeClone(java.lang.Object rmiClone)
shallowMergeClone in interface UnitOfWorkmergeClone(Object),
deepMergeClone(Object)public java.lang.Object shallowRevertObject(java.lang.Object clone)
shallowRevertObject in interface UnitOfWorkrevertObject(Object),
deepRevertObject(Object)public void shallowUnregisterObject(java.lang.Object clone)
shallowUnregisterObject in interface UnitOfWorkpublic boolean shouldCascadeCloneToJoinedRelationship()
public boolean shouldNewObjectsBeCached()
shouldNewObjectsBeCached in interface UnitOfWorkpublic boolean shouldPerformDeletesFirst()
shouldPerformDeletesFirst in interface UnitOfWorkpublic boolean shouldPerformFullValidation()
shouldPerformFullValidation in interface UnitOfWorkpublic boolean shouldPerformNoValidation()
shouldPerformNoValidation in interface UnitOfWorkpublic boolean shouldPerformPartialValidation()
shouldPerformPartialValidation in interface UnitOfWorkpublic boolean shouldResumeUnitOfWorkOnTransactionCompletion()
public void storeModifyAllQuery(DatabaseQuery query)
public void storeDeferredModifyAllQuery(DatabaseQuery query, AbstractRecord translationRow)
public void synchronizeAndResume()
protected void undeleteObject(java.lang.Object object)
public void unregisterObject(java.lang.Object clone)
unregisterObject in interface UnitOfWorkpublic void unregisterObject(java.lang.Object clone,
int cascadeDepth)
public void updateChangeTrackersIfRequired(java.lang.Object objectToWrite,
ObjectChangeSet changeSetToWrite,
UnitOfWorkImpl uow,
ClassDescriptor descriptor)
public void validateObjectSpace()
validateObjectSpace in interface UnitOfWorkpublic boolean wasTransactionBegunPrematurely()
public void writeChanges()
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.
writeChanges in interface UnitOfWorkpublic void writesCompleted()
writesCompleted in class AbstractSessionpublic java.lang.Object getWorkingCopyFromUnitOfWorkIdentityMap(java.lang.Object object,
java.util.Vector primaryKey)
public IdentityHashtable getPessimisticLockedObjects()
public void addPessimisticLockedClone(java.lang.Object clone)
public boolean isPessimisticLocked(java.lang.Object clone)
public void setWasNonObjectLevelModifyQueryExecuted(boolean wasNonObjectLevelModifyQueryExecuted)
public boolean wasNonObjectLevelModifyQueryExecuted()
public boolean shouldReadFromDB()
public void clear(boolean shouldClearCache)
public void clearForClose(boolean shouldClearCache)
public boolean shouldClearForCloseOnRelease()