public interface UnitOfWork extends Session
Description: The unit of work is a session that implements all of the normal protocol of an EclipseLink session. It can be spawned from any other session including another unit of work. Objects can be brought into the unit of work through reading them or through registering them. The unit of work will operate on its own object space, that is the objects within the unit of work will be clones of the original objects. When the unit of work is committed, all changes to any objects registered within the unit of work will be committed to the database. A minimal commit/update will be performed and any foreign keys/circular reference/referential integrity will be resolved. If the commit to the database is successful the changed objects will be merged back into the unit of work parent session.
Responsibilities:
Modifier and Type | Interface and Description |
---|---|
static class |
UnitOfWork.CommitOrderType
Defines the ordering of updates and deletes of a set of the same entity type during a commit or flush operation.
|
Modifier and Type | Method and Description |
---|---|
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.Collection classes)
PUBLIC:
Adds the classes in the given Vector to the existing set of read-only classes.
|
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.
|
void |
beginEarlyTransaction()
PUBLIC:
Tell the unit of work to begin a transaction now.
|
void |
commit()
PUBLIC:
Commit the unit of work to its parent.
|
void |
commitAndResume()
PUBLIC:
Commit the unit of work to its parent.
|
void |
commitAndResumeOnFailure()
PUBLIC:
Commit the unit of work to its parent.
|
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.Collection domainObjects)
PUBLIC:
Delete all of the objects and all of their privately owned parts in the database.
|
java.lang.Object |
deleteObject(java.lang.Object domainObject)
PUBLIC:
Delete the object and all of their privately owned parts in the database.
|
void |
dontPerformValidation()
ADVANCED:
The unit of work performs validations such as,
ensuring multiple copies of the same object don't exist in the same unit of work,
ensuring deleted objects are not referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
void |
forceUpdateToVersionField(java.lang.Object cloneFromUOW,
boolean shouldModifyVersionField)
ADVANCED:
Set optimistic read lock on the object.
|
UnitOfWork.CommitOrderType |
getCommitOrder()
ADVANCED:
Return the commit order.
|
UnitOfWorkChangeSet |
getCurrentChanges()
ADVANCED:
This method will calculate the changes for the UnitOfWork.
|
java.lang.Object |
getOriginalVersionOfObject(java.lang.Object workingClone)
ADVANCED:
Return the original version of the object(clone) from the parent's identity map.
|
org.eclipse.persistence.internal.sessions.AbstractSession |
getParent()
PUBLIC:
Return the parent.
|
java.util.Set |
getReadOnlyClasses()
ADVANCED:
Returns the set of read-only classes in this UnitOfWork.
|
java.lang.Object |
getReference(java.lang.Class theClass,
java.lang.Object primaryKey)
Get an instance, whose state may be lazily fetched.
|
UnitOfWorkChangeSet |
getUnitOfWorkChangeSet()
ADVANCED:
Returns the currentChangeSet from the UnitOfWork.
|
int |
getValidationLevel()
ADVANCED:
The unit of work performs validations such as,
ensuring multiple copies of the same object don't exist in the same unit of work,
ensuring deleted objects are not referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
boolean |
hasChanges()
ADVANCED:
The Unit of work is capable of preprocessing to determine if any on the clone have been changed.
|
boolean |
isActive()
PUBLIC:
Return if the unit of work is active (has not been released).
|
boolean |
isClassReadOnly(java.lang.Class theClass)
PUBLIC:
Checks to see if the specified class is read-only or not in this UnitOfWork.
|
boolean |
isNestedUnitOfWork()
ADVANCED:
Return if this session is a nested unit of work.
|
boolean |
isObjectRegistered(java.lang.Object clone)
ADVANCED:
Return whether the clone object is already registered.
|
java.lang.Object |
mergeClone(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)
PUBLIC:
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 referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
void |
performPartialValidation()
ADVANCED:
The unit of work performs validations such as,
ensuring multiple copies of the same object don't exist in the same unit of work,
ensuring deleted objects are not referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
void |
printRegisteredObjects()
PUBLIC:
Print the objects in the unit of work.
|
java.lang.Object |
refreshAndLockObject(java.lang.Object object)
PUBLIC:
Refresh the attributes of the object and of all of its private parts from the database.
|
java.lang.Object |
refreshAndLockObject(java.lang.Object object,
short lockMode)
PUBLIC:
Refresh the attributes of the object and of all of its private parts from the database.
|
java.util.Vector |
registerAllObjects(java.util.Collection 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.
|
java.lang.Object |
registerNewObject(java.lang.Object newObject)
ADVANCED:
Register the new object with the unit of work.
|
java.lang.Object |
registerObject(java.lang.Object domainObject)
PUBLIC:
Register the object with the unit of work.
|
void |
release()
PUBLIC:
Release the unit of work.
|
void |
removeAllReadOnlyClasses()
PUBLIC:
Empties the set of read-only classes.
|
void |
removeForceUpdateToVersionField(java.lang.Object cloneFromUOW)
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.
|
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.
|
void |
setCommitOrder(UnitOfWork.CommitOrderType order)
ADVANCED:
Set the commit order.
|
void |
setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached)
ADVANCED:
By default new objects are not cached until the exist on the database.
|
void |
setShouldOrderUpdates(boolean shouldOrderUpdates)
Deprecated.
since 2.6 replaced by #setCommitOrder(CommitOrderType)
|
void |
setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst)
ADVANCED:
By default deletes are performed last in a unit of work.
|
void |
setShouldThrowConformExceptions(int shouldThrowExceptions)
ADVANCED:
Conforming queries can be set to provide different levels of detail about the
exceptions they encounter
There are two levels:
DO_NOT_THROW_CONFORM_EXCEPTIONS = 0; THROW_ALL_CONFORM_EXCEPTIONS = 1; |
void |
setValidationLevel(int validationLevel)
ADVANCED:
The unit of work performs validations such as,
ensuring multiple copies of the same object don't exist in the same unit of work,
ensuring deleted objects are not referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
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 |
shouldNewObjectsBeCached()
ADVANCED:
By default new objects are not cached until the exist on the database.
|
boolean |
shouldOrderUpdates()
Deprecated.
since 2.6 replaced by #getCommitOrder()
|
boolean |
shouldPerformDeletesFirst()
ADVANCED:
By default all objects are inserted and updated in the database before
any object is deleted.
|
boolean |
shouldPerformFullValidation()
ADVANCED:
The unit of work performs validations such as,
ensuring multiple copies of the same object don't exist in the same unit of work,
ensuring deleted objects are not referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
boolean |
shouldPerformNoValidation()
ADVANCED:
The unit of work performs validations such as,
ensuring multiple copies of the same object don't exist in the same unit of work,
ensuring deleted objects are not referred after commit,
ensures that objects from the parent cache are not referred 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 referred after commit,
ensures that objects from the parent cache are not referred in the unit of work cache.
|
void |
unregisterObject(java.lang.Object clone)
ADVANCED:
Unregister the object with the unit of work.
|
void |
validateObjectSpace()
ADVANCED:
This can be used to help debugging an object-space corruption.
|
void |
writeChanges()
ADVANCED: Writes all changes now before commit().
|
acquireHistoricalSession, acquireUnitOfWork, acquireUnitOfWork, addJPAQuery, addQuery, clearIntegrityChecker, clearProfile, containsQuery, copy, copy, copyObject, copyObject, doesObjectExist, dontLogMessages, executeNonSelectingCall, executeNonSelectingSQL, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeQuery, executeSelectingCall, executeSQL, getActiveSession, getActiveUnitOfWork, getAsOfClause, getClassDescriptor, getClassDescriptor, getClassDescriptorForAlias, getDatasourceLogin, getDatasourcePlatform, getDefaultReferenceMode, getDescriptor, getDescriptor, getDescriptorForAlias, getDescriptors, getEventManager, getExceptionHandler, getExternalTransactionController, getId, getIdentityMapAccessor, getIntegrityChecker, getJPAQueries, getLog, getLogin, getLogLevel, getLogLevel, getName, getNextSequenceNumberValue, getPartitioningPolicy, getPlatform, getProfiler, getProject, getProperties, getProperty, getQueries, getQuery, getQuery, getSerializer, getServerPlatform, getSessionLog, handleException, handleSevere, hasDescriptor, hasExceptionHandler, hasExternalTransactionController, isClientSession, isConnected, isDatabaseSession, isDistributedSession, isFinalizersEnabled, isInProfile, isRemoteSession, isRemoteUnitOfWork, isServerSession, isSessionBroker, isUnitOfWork, keyFromObject, log, logMessage, readAllObjects, readAllObjects, readAllObjects, readObject, readObject, readObject, readObject, refreshObject, removeProperty, removeQuery, setDefaultReferenceMode, setExceptionHandler, setExternalTransactionController, setIntegrityChecker, setIsFinalizersEnabled, setLog, setLogLevel, setName, setPartitioningPolicy, setProfiler, setProperty, setQueryTimeoutDefault, setQueryTimeoutUnitDefault, setSerializer, setSessionLog, shouldLog, shouldLogMessages, validateCache
java.util.Set getReadOnlyClasses()
void addReadOnlyClass(java.lang.Class theClass)
void addReadOnlyClasses(java.util.Collection classes)
void assignSequenceNumber(java.lang.Object object) throws DatabaseException
DatabaseException
void assignSequenceNumbers() throws DatabaseException
DatabaseException
void beginEarlyTransaction() throws DatabaseException
DatabaseException
commit()
,
release()
void commit() throws DatabaseException, OptimisticLockException
DatabaseException
OptimisticLockException
commitAndResumeOnFailure()
,
commitAndResume()
,
release()
void commitAndResume() throws DatabaseException, OptimisticLockException
DatabaseException
OptimisticLockException
commitAndResumeOnFailure()
,
commit()
,
release()
void commitAndResumeOnFailure() throws DatabaseException, OptimisticLockException
DatabaseException
OptimisticLockException
commit()
,
release()
java.lang.Object deepMergeClone(java.lang.Object rmiClone)
mergeClone(Object)
,
shallowMergeClone(Object)
java.lang.Object deepRevertObject(java.lang.Object clone)
revertObject(Object)
,
shallowRevertObject(Object)
void deepUnregisterObject(java.lang.Object clone)
void deleteAllObjects(java.util.Collection domainObjects)
java.lang.Object deleteObject(java.lang.Object domainObject)
void dontPerformValidation()
void forceUpdateToVersionField(java.lang.Object cloneFromUOW, boolean shouldModifyVersionField)
UnitOfWorkChangeSet getCurrentChanges()
java.lang.Object getOriginalVersionOfObject(java.lang.Object workingClone)
org.eclipse.persistence.internal.sessions.AbstractSession getParent()
UnitOfWorkChangeSet getUnitOfWorkChangeSet()
int getValidationLevel()
boolean hasChanges()
boolean isActive()
boolean isClassReadOnly(java.lang.Class theClass)
boolean isObjectRegistered(java.lang.Object clone)
boolean isNestedUnitOfWork()
java.lang.Object mergeClone(java.lang.Object rmiClone)
shallowMergeClone(Object)
,
deepMergeClone(Object)
java.lang.Object mergeCloneWithReferences(java.lang.Object rmiClone)
shallowMergeClone(Object)
,
deepMergeClone(Object)
java.lang.Object newInstance(java.lang.Class theClass)
void performFullValidation()
void performPartialValidation()
void printRegisteredObjects()
java.lang.Object refreshAndLockObject(java.lang.Object object)
refreshAndLockObject(Object, short)
java.lang.Object refreshAndLockObject(java.lang.Object object, short lockMode)
Lock Modes: ObjectBuildingQuery.NO_LOCK, LOCK, LOCK_NOWAIT
java.util.Vector registerAllObjects(java.util.Collection domainObjects)
java.lang.Object registerExistingObject(java.lang.Object existingObject)
java.lang.Object registerNewObject(java.lang.Object newObject)
registerObject(Object)
java.lang.Object registerObject(java.lang.Object domainObject)
void release()
void removeAllReadOnlyClasses()
void removeForceUpdateToVersionField(java.lang.Object cloneFromUOW)
void removeReadOnlyClass(java.lang.Class theClass)
void revertAndResume()
commitAndResume()
,
release()
java.lang.Object revertObject(java.lang.Object clone)
shallowRevertObject(Object)
,
deepRevertObject(Object)
void setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached)
void setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst)
void setShouldThrowConformExceptions(int shouldThrowExceptions)
void setValidationLevel(int validationLevel)
java.lang.Object shallowMergeClone(java.lang.Object rmiClone)
mergeClone(Object)
,
deepMergeClone(Object)
java.lang.Object shallowRevertObject(java.lang.Object clone)
revertObject(Object)
,
deepRevertObject(Object)
void shallowUnregisterObject(java.lang.Object clone)
boolean shouldNewObjectsBeCached()
boolean shouldPerformDeletesFirst()
boolean shouldPerformFullValidation()
boolean shouldPerformNoValidation()
boolean shouldPerformPartialValidation()
void unregisterObject(java.lang.Object clone)
void validateObjectSpace()
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 marked 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.
java.lang.Object getReference(java.lang.Class theClass, java.lang.Object primaryKey)
primaryKey
- - The primary key of the object, either as a List, singleton, IdClass or an instance of the object.@Deprecated boolean shouldOrderUpdates()
@Deprecated void setShouldOrderUpdates(boolean shouldOrderUpdates)
UnitOfWork.CommitOrderType getCommitOrder()
void setCommitOrder(UnitOfWork.CommitOrderType order)