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 FormModifier 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 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 String |
LOCK_QUERIES_PROPERTY |
static int |
MergePending |
protected List |
modifyAllQueries
lazy initialization done in storeModifyAllQuery.
|
protected IdentityHashtable |
newAggregates |
protected IdentityHashtable |
newObjectsCloneToOriginal |
protected IdentityHashtable |
newObjectsOriginalToClone |
static int |
None |
protected IdentityHashtable |
objectsDeletedDuringCommit |
protected Map |
objectsLockedForClone
This collection will be used to store those objects that are currently locked
for the clone process.
|
protected Hashtable |
optimisticReadLockObjects
Kept reference of read lock objects
|
protected AbstractSession |
parent |
static int |
Partial |
protected IdentityHashtable |
pessimisticLockedObjects
use to track pessimistic locked objects
|
protected 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 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(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 |
addReadOnlyClass(Class theClass)
PUBLIC:
Adds the given Java class to the receiver's set of read-only classes.
|
void |
addReadOnlyClasses(Vector 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 |
afterTransaction(boolean committed,
boolean isExternalTransaction)
INTERNAL:
Called after transaction is completed (committed or rolled back)
|
void |
assignSequenceNumber(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.
|
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(IdentityHashtable allObjects,
UnitOfWorkChangeSet changeSet)
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:
|
protected 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 used for comitting transactions:
all the changes sets will be dereferenced, and (optionally) the cache cleared.
|
protected Object |
cloneAndRegisterNewObject(Object original)
ADVANCED:
Register the new object with the unit of work.
|
Object |
cloneAndRegisterObject(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.
|
Vector |
copyReadOnlyClasses()
INTERNAL:
Copy the read only classes from the unit of work.
|
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.
|
void |
deleteAllObjects(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(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.
|
Object |
executeCall(Call call,
AbstractRecord translationRow,
DatabaseQuery query)
INTERNAL:
Override From session.
|
void |
forceUpdateToVersionField(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(Class domainClass)
INTERNAL:
The uow does not store a local accessor but shares its parents.
|
Accessor |
getAccessor(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
|
Vector |
getAllFromNewObjects(Expression selectionCriteria,
Class theClass,
AbstractRecord translationRow,
InMemoryQueryIndirectionPolicy valueHolderPolicy)
INTERNAL:
Return any new objects matching the expression.
|
Object |
getBackupClone(Object clone)
INTERNAL:
Return the backup clone for the working clone.
|
Object |
getBackupCloneForCommit(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.
|
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(String alias)
PUBLIC:
Return the descriptor for the alias.
|
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.
|
Object |
getObjectFromNewObjects(Class theClass,
Vector selectionKey)
INTERNAL:
Return any new object matching the expression.
|
Object |
getObjectFromNewObjects(Expression selectionCriteria,
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.
|
Hashtable |
getOptimisticReadLockObjects()
INTERNAL:
Return optimistic read lock objects
|
Object |
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)
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(Class domainClass)
INTERNAL:
Return the platform for a particular class.
|
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.
|
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)
|
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.
|
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.
|
Object |
getWorkingCopyFromUnitOfWorkIdentityMap(Object object,
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.
|
Object |
internalExecuteQuery(DatabaseQuery query,
AbstractRecord databaseRow)
INTERNAL:
Return the results from exeucting the database query.
|
Object |
internalRegisterObject(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(Class theClass,
ClassDescriptor descriptor)
PUBLIC:
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 |
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(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 UnitOfWork
|
boolean |
isObjectRegistered(Object clone)
INTERNAL:
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:
|
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.
|
Object |
mergeClone(Object rmiClone)
PUBLIC:
Merge the attributes of the clone into the unit of work copy.
|
Object |
mergeClone(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
|
Object |
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 |
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 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(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(Object original,
Object workingClone,
Vector primaryKey,
ClassDescriptor descriptor,
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.
|
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
|
Vector |
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.
|
protected Object |
registerExistingObject(Object objectToRegister,
ClassDescriptor descriptor,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
Register the existing object with the unit of work.
|
Object |
registerExistingObject(Object existingObject,
JoinedAttributeManager joinedAttributeManager)
INTERNAL:
Register the existing object 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)
INTERNAL:
Register the working copy of a new object and its original.
|
void |
registerNewObjectForPersist(Object newObject,
IdentityHashtable visitedObjects)
INTERNAL:
Register the new object with the unit of work.
|
protected void |
registerNewObjectInIdentityMap(Object clone,
Object original)
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 |
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(Object lockObject)
ADVANCED:
Remove optimistic read lock from the object
See forceUpdateToVersionField(Object)
|
void |
removeReadOnlyClass(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.
|
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 explictly in a uow.
|
protected void |
rollbackTransaction(boolean intendedToCommitTransaction)
INTERNAL:
rollbackTransaction() with a twist for external transactions.
|
IdentityHashtable |
scanForConformingInstances(Expression selectionCriteria,
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(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(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.
|
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 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(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 |
updateChangeTrackersIfRequired(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, writeObject
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
deleteAllObjects, deleteObject, isClassReadOnly, refreshAndLockObject, refreshAndLockObject
addEjbqlPlaceHolderQuery, 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, shouldLogMessages
protected 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 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 String LOCK_QUERIES_PROPERTY
protected static boolean SmartMerge
protected Hashtable optimisticReadLockObjects
protected List modifyAllQueries
protected List deferredModifyAllQueries
protected int cloneDepth
protected Map objectsLockedForClone
protected Object transaction
protected boolean shouldCheckWriteLock
protected boolean resumeOnTransactionCompletion
protected boolean wasNonObjectLevelModifyQueryExecuted
protected boolean shouldCascadeCloneToJoinedRelationship
public UnitOfWorkImpl(AbstractSession parent)
public UnitOfWork acquireUnitOfWork()
acquireUnitOfWork
in interface Session
acquireUnitOfWork
in class AbstractSession
UnitOfWork
public void addNewAggregate(Object originalObject)
public void addObjectDeletedDuringCommit(Object object, ClassDescriptor descriptor)
public void addReadOnlyClass(Class theClass) throws ValidationException
addReadOnlyClass
in interface UnitOfWork
ValidationException
public void addReadOnlyClasses(Vector classes)
addReadOnlyClasses
in interface UnitOfWork
public void addRemovedObject(Object orignal)
public void assignSequenceNumber(Object object) throws DatabaseException
assignSequenceNumber
in interface UnitOfWork
DatabaseException
public void assignSequenceNumbers() throws DatabaseException
assignSequenceNumbers
in interface UnitOfWork
DatabaseException
public void beginEarlyTransaction() throws DatabaseException
beginEarlyTransaction
in interface UnitOfWork
DatabaseException
commit()
,
release()
public void beginTransaction() throws DatabaseException
beginTransaction
in class AbstractSession
DatabaseException
- if the database connection is lost or the begin is rejected.AbstractSession.isInTransaction()
public Object buildOriginal(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(Object object)
public Object checkExistence(Object object)
protected Object checkIfAlreadyRegistered(Object object, ClassDescriptor descriptor)
protected Object cloneAndRegisterNewObject(Object original)
registerObject(Object)
public Object cloneAndRegisterObject(Object original, CacheKey cacheKey, JoinedAttributeManager joinedAttributeManager)
public IdentityHashtable collectAndPrepareObjectsForCommit()
public IdentityHashtable collectAndPrepareObjectsForNestedMerge()
public void commit() throws DatabaseException, OptimisticLockException
commit
in interface UnitOfWork
DatabaseException
OptimisticLockException
commitAndResumeOnFailure()
,
commitAndResume()
,
release()
public void commitAndResume() throws DatabaseException, OptimisticLockException
commitAndResume
in interface UnitOfWork
DatabaseException
OptimisticLockException
commitAndResumeOnFailure()
,
commit()
,
release()
public void commitAndResumeWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet) throws DatabaseException, OptimisticLockException
public void commitAndResumeOnFailure() throws DatabaseException, OptimisticLockException
commitAndResumeOnFailure
in interface UnitOfWork
DatabaseException
OptimisticLockException
commit()
,
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.DatabaseException
OptimisticLockException
protected void commitToDatabaseWithPreBuiltChangeSet(UnitOfWorkChangeSet uowChangeSet, boolean commitTransaction) throws DatabaseException, OptimisticLockException
public void commitTransaction() throws DatabaseException
commitTransaction
in class AbstractSession
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.protected void commitTransactionAfterWriteChanges()
public Vector copyReadOnlyClasses()
copyReadOnlyClasses
in class AbstractSession
public Object deepMergeClone(Object rmiClone)
deepMergeClone
in interface UnitOfWork
mergeClone(Object)
,
shallowMergeClone(Object)
public Object deepRevertObject(Object clone)
deepRevertObject
in interface UnitOfWork
revertObject(Object)
,
shallowRevertObject(Object)
public void deepUnregisterObject(Object clone)
deepUnregisterObject
in interface UnitOfWork
public void deleteAllObjects(Vector domainObjects)
deleteAllObjects
in interface UnitOfWork
deleteAllObjects
in class AbstractSession
protected void discoverAllUnregisteredNewObjects()
public void discoverUnregisteredNewObjects(Object clone, IdentityHashtable knownNewObjects, IdentityHashtable unregisteredExistingObjects, IdentityHashtable visitedObjects)
public void dontPerformValidation()
dontPerformValidation
in interface UnitOfWork
public Object executeCall(Call call, AbstractRecord translationRow, DatabaseQuery query) throws DatabaseException
executeCall
in class AbstractSession
DatabaseException
public void forceUpdateToVersionField(Object lockObject, boolean shouldModifyVersionField)
forceUpdateToVersionField
in interface UnitOfWork
public Accessor getAccessor()
getAccessor
in class AbstractSession
public CommitManager getCommitManager()
getCommitManager
in class AbstractSession
public Accessor getAccessor(Class domainClass)
getAccessor
in class AbstractSession
public Accessor getAccessor(String sessionName)
getAccessor
in class AbstractSession
public UnitOfWork getActiveUnitOfWork()
getActiveUnitOfWork
in interface Session
getActiveUnitOfWork
in class AbstractSession
protected IdentityHashtable getAllClones()
public Vector getAllFromNewObjects(Expression selectionCriteria, Class theClass, AbstractRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy)
public Object getBackupClone(Object clone) throws QueryException
QueryException
public Object getBackupCloneForCommit(Object clone)
public UnitOfWorkChangeSet getCurrentChanges()
getCurrentChanges
in interface UnitOfWork
public 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 AbstractSession
canReturnSelf
- 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 AbstractSession
query
- 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 Vector getDefaultReadOnlyClasses()
getDefaultReadOnlyClasses
in class AbstractSession
Project.setDefaultReadOnlyClasses(Vector)
public IdentityHashtable getDeletedObjects()
protected boolean hasDeletedObjects()
public ClassDescriptor getDescriptorForAlias(String alias)
getDescriptorForAlias
in interface Session
getDescriptorForAlias
in class AbstractSession
public Map getDescriptors()
getDescriptors
in interface Session
getDescriptors
in class AbstractSession
public int getLifecycle()
public MergeManager getMergeManager()
public IdentityHashtable getNewAggregates()
public IdentityHashtable getNewObjectsCloneToOriginal()
public IdentityHashtable getNewObjectsOriginalToClone()
public Sequencing getSequencing()
getSequencing
in class AbstractSession
public ServerPlatform getServerPlatform()
getServerPlatform
in class AbstractSession
public 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 AbstractSession
public void afterTransaction(boolean committed, boolean isExternalTransaction)
afterTransaction
in class AbstractSession
public Object getObjectFromNewObjects(Class theClass, Vector selectionKey)
public Object getObjectFromNewObjects(Expression selectionCriteria, Class theClass, AbstractRecord translationRow, InMemoryQueryIndirectionPolicy valueHolderPolicy)
public IdentityHashtable getObjectsDeletedDuringCommit()
protected boolean hasObjectsDeletedDuringCommit()
public Hashtable getOptimisticReadLockObjects()
public Object getOriginalVersionOfNewObject(Object workingClone)
public Object getOriginalVersionOfObject(Object workingClone)
getOriginalVersionOfObject
in interface UnitOfWork
public Object getOriginalVersionOfObjectOrNull(Object workingClone)
public AbstractSession getParent()
getParent
in interface UnitOfWork
public Platform getPlatform(Class domainClass)
getPlatform
in class AbstractSession
public int getShouldThrowConformExceptions()
public DatabaseQuery getQuery(String name, Vector arguments)
getQuery
in interface Session
getQuery
in class AbstractSession
AbstractSession.getQuery(String)
public DatabaseQuery getQuery(String name)
getQuery
in interface Session
getQuery
in class AbstractSession
public Hashtable getReadOnlyClasses()
setReadOnlyClasses(Vector)
protected IdentityHashtable getRemovedObjects()
protected boolean hasRemovedObjects()
protected boolean hasModifyAllQueries()
protected boolean hasDeferredModifyAllQueries()
public int getState()
public Object getTransaction()
public void setTransaction(Object transaction)
public UnitOfWorkChangeSet getUnitOfWorkChangeSet()
getUnitOfWorkChangeSet
in interface UnitOfWork
public IdentityHashtable getUnregisteredExistingObjects()
protected IdentityHashtable getUnregisteredNewObjects()
public int getValidationLevel()
getValidationLevel
in interface UnitOfWork
public boolean hasChanges()
hasChanges
in interface UnitOfWork
protected boolean hasModifications()
Note if a transaction was begun prematurely it still needs to be committed.
public void initializeIdentityMapAccessor()
initializeIdentityMapAccessor
in class AbstractSession
public Object internalExecuteQuery(DatabaseQuery query, AbstractRecord databaseRow) throws DatabaseException, QueryException
internalExecuteQuery
in class AbstractSession
DatabaseException
QueryException
public Object internalRegisterObject(Object object, ClassDescriptor descriptor)
public boolean isActive()
isActive
in interface UnitOfWork
public boolean isClassReadOnly(Class theClass, ClassDescriptor descriptor)
isClassReadOnly
in class AbstractSession
public boolean isCloneNewObject(Object clone)
public boolean isCommitPending()
public boolean isDead()
public boolean isInTransaction()
isInTransaction
in class AbstractSession
public boolean isMergePending()
public boolean isAfterWriteChangesButBeforeCommit()
protected boolean isAfterWriteChangesFailed()
public boolean isNestedUnitOfWork()
isNestedUnitOfWork
in interface UnitOfWork
public boolean isObjectDeleted(Object object)
public boolean isObjectNew(Object clone)
public boolean isObjectRegistered(Object clone)
public boolean isOriginalNewObject(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 Session
isUnitOfWork
in class AbstractSession
protected void mergeChangesIntoParent()
public Object mergeClone(Object rmiClone)
mergeClone
in interface UnitOfWork
shallowMergeClone(Object)
,
deepMergeClone(Object)
public Object mergeClone(Object rmiClone, int cascadeDepth)
public void mergeClonesAfterCompletion()
public Object mergeCloneWithReferences(Object rmiClone)
mergeCloneWithReferences
in interface UnitOfWork
shallowMergeClone(Object)
,
deepMergeClone(Object)
public Object mergeCloneWithReferences(Object rmiClone, int cascadePolicy)
shallowMergeClone(Object)
,
deepMergeClone(Object)
public Object mergeCloneWithReferences(Object rmiClone, int cascadePolicy, boolean forceCascade)
shallowMergeClone(Object)
,
deepMergeClone(Object)
public Object newInstance(Class theClass)
newInstance
in interface UnitOfWork
public void performRemove(Object toBeDeleted, IdentityHashtable visitedObjects)
public void performFullValidation()
performFullValidation
in interface UnitOfWork
public void performPartialValidation()
performPartialValidation
in interface UnitOfWork
protected void populateAndRegisterObject(Object original, Object workingClone, Vector primaryKey, ClassDescriptor descriptor, Object writeLockValue, long readTime, JoinedAttributeManager joinedAttributeManager)
protected void postMergeChanges()
protected void preMergeChanges()
public void printRegisteredObjects()
printRegisteredObjects
in interface UnitOfWork
public Object processDeleteObjectQuery(DeleteObjectQuery deleteQuery)
protected void basicPrintRegisteredObjects()
public Vector registerAllObjects(Collection domainObjects)
registerAllObjects
in interface UnitOfWork
public Vector registerAllObjects(Vector domainObjects) throws DatabaseException, OptimisticLockException
registerAllObjects
in interface UnitOfWork
DatabaseException
OptimisticLockException
public Object registerExistingObject(Object existingObject, JoinedAttributeManager joinedAttributeManager)
public Object registerExistingObject(Object existingObject)
registerExistingObject
in interface UnitOfWork
protected Object registerExistingObject(Object objectToRegister, ClassDescriptor descriptor, JoinedAttributeManager joinedAttributeManager)
public Object registerNewObject(Object newObject)
registerNewObject
in interface UnitOfWork
registerObject(Object)
protected Object registerNewObject(Object implementation, ClassDescriptor descriptor)
registerObject(Object)
public void registerNewObjectForPersist(Object newObject, IdentityHashtable visitedObjects)
registerObject(Object)
protected void registerNotRegisteredNewObjectForPersist(Object newObject, ClassDescriptor descriptor)
protected void registerNewObjectClone(Object clone, Object original)
protected void registerNewObjectInIdentityMap(Object clone, Object original)
public Object registerObject(Object object)
registerObject
in interface UnitOfWork
protected Object registerObject(Object object, ClassDescriptor descriptor)
public void registerWithTransactionIfRequired()
public void release()
release
in interface Session
release
in interface UnitOfWork
release
in class AbstractSession
commit()
public void removeAllReadOnlyClasses() throws ValidationException
removeAllReadOnlyClasses
in interface UnitOfWork
ValidationException
public void removeForceUpdateToVersionField(Object lockObject)
removeForceUpdateToVersionField
in interface UnitOfWork
public void removeReadOnlyClass(Class theClass) throws ValidationException
removeReadOnlyClass
in interface UnitOfWork
ValidationException
protected void resetAllCloneCollection()
public void revertAndResume()
revertAndResume
in interface UnitOfWork
commitAndResume()
,
release()
public Object revertObject(Object clone)
revertObject
in interface UnitOfWork
shallowRevertObject(Object)
,
deepRevertObject(Object)
public Object revertObject(Object clone, int cascadeDepth)
public void rollbackTransaction() throws DatabaseException
rollbackTransaction
in class AbstractSession
DatabaseException
- 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.DatabaseException
public IdentityHashtable scanForConformingInstances(Expression selectionCriteria, 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(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 UnitOfWork
public void setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst)
setShouldPerformDeletesFirst
in interface UnitOfWork
public void setShouldThrowConformExceptions(int shouldThrowExceptions)
setShouldThrowConformExceptions
in interface UnitOfWork
public 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 UnitOfWork
public void setWasTransactionBegunPrematurely(boolean wasTransactionBegunPrematurely)
public Object shallowMergeClone(Object rmiClone)
shallowMergeClone
in interface UnitOfWork
mergeClone(Object)
,
deepMergeClone(Object)
public Object shallowRevertObject(Object clone)
shallowRevertObject
in interface UnitOfWork
revertObject(Object)
,
deepRevertObject(Object)
public void shallowUnregisterObject(Object clone)
shallowUnregisterObject
in interface UnitOfWork
public boolean shouldCascadeCloneToJoinedRelationship()
public boolean shouldNewObjectsBeCached()
shouldNewObjectsBeCached
in interface UnitOfWork
public boolean shouldPerformDeletesFirst()
shouldPerformDeletesFirst
in interface UnitOfWork
public boolean shouldPerformFullValidation()
shouldPerformFullValidation
in interface UnitOfWork
public boolean shouldPerformNoValidation()
shouldPerformNoValidation
in interface UnitOfWork
public boolean shouldPerformPartialValidation()
shouldPerformPartialValidation
in interface UnitOfWork
public boolean shouldResumeUnitOfWorkOnTransactionCompletion()
public void storeModifyAllQuery(DatabaseQuery query)
public void storeDeferredModifyAllQuery(DatabaseQuery query, AbstractRecord translationRow)
public void synchronizeAndResume()
protected void undeleteObject(Object object)
public void unregisterObject(Object clone)
unregisterObject
in interface UnitOfWork
public void unregisterObject(Object clone, int cascadeDepth)
public void updateChangeTrackersIfRequired(Object objectToWrite, ObjectChangeSet changeSetToWrite, UnitOfWorkImpl uow, ClassDescriptor descriptor)
public void validateObjectSpace()
validateObjectSpace
in interface UnitOfWork
public 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 UnitOfWork
public void writesCompleted()
writesCompleted
in class AbstractSession
public Object getWorkingCopyFromUnitOfWorkIdentityMap(Object object, Vector primaryKey)
public IdentityHashtable getPessimisticLockedObjects()
public void addPessimisticLockedClone(Object clone)
public boolean isPessimisticLocked(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()
Copyright © 2023. All rights reserved.