Top Description Inners Methods
org.eclipse.persistence.sessions

public Interface UnitOfWork

extends Session
Known Direct Implementers
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl
Imports
java.util.Collection, .Set, .Vector, org.eclipse.persistence.exceptions.DatabaseException, .OptimisticLockException, org.eclipse.persistence.sessions.changesets.UnitOfWorkChangeSet

Purpose: To allow object level transactions. This class represents the public API of the unit of work and should be used to maintain complete compatibility.

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:

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
UnitOfWork.CommitOrderType

Defines the ordering of updates and deletes of a set of the same entity type during a commit or flush operation.

Method Summary

Modifier and TypeMethod and Description
public void
addReadOnlyClass(Class<?> theClass)

PUBLIC: Adds the given Java class to the receiver's set of read-only classes.

public void
addReadOnlyClasses(Collection<E> classes)

PUBLIC: Adds the classes in the given Vector to the existing set of read-only classes.

public void
assignSequenceNumber(Object object)

ADVANCED: Assign sequence number to the object.

public 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.

public void
beginEarlyTransaction()

PUBLIC: Tell the unit of work to begin a transaction now.

public void
commit()

PUBLIC: Commit the unit of work to its parent.

public void
commitAndResume()

PUBLIC: Commit the unit of work to its parent.

public void
commitAndResumeOnFailure()

PUBLIC: Commit the unit of work to its parent.

public Object

Returns:

the registered version for the clone being merged.
deepMergeClone
(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy.

public Object

Returns:

the object reverted.
deepRevertObject
(Object clone)

PUBLIC: Revert the object's attributes from the parent.

public void
deepUnregisterObject(Object clone)

ADVANCED: Unregister the object with the unit of work.

public void
deleteAllObjects(Collection<E> domainObjects)

PUBLIC: Delete all of the objects and all of their privately owned parts in the database.

public Object
deleteObject(Object domainObject)

PUBLIC: Delete the object and all of their privately owned parts in the database.

public void
dontPerformValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public void
forceUpdateToVersionField(Object cloneFromUOW, boolean shouldModifyVersionField)

ADVANCED: Set optimistic read lock on the object.

public UnitOfWork.CommitOrderType
getCommitOrder()

ADVANCED: Return the commit order.

public UnitOfWorkChangeSet
getCurrentChanges()

ADVANCED: This method will calculate the changes for the UnitOfWork.

public Object
getOriginalVersionOfObject(Object workingClone)

ADVANCED: Return the original version of the object(clone) from the parent's identity map.

public AbstractSession
getParent()

PUBLIC: Return the parent.

public Set<E>
getReadOnlyClasses()

ADVANCED: Returns the set of read-only classes in this UnitOfWork.

public Object
getReference(Class<?> theClass, Object
- The primary key of the object, either as a List, singleton, IdClass or an instance of the object.
primaryKey
)

Get an instance, whose state may be lazily fetched.

public UnitOfWorkChangeSet
getUnitOfWorkChangeSet()

ADVANCED: Returns the currentChangeSet from the UnitOfWork.

public int
getValidationLevel()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public boolean
hasChanges()

ADVANCED: The Unit of work is capable of preprocessing to determine if any on the clone have been changed.

public boolean
isActive()

PUBLIC: Return if the unit of work is active (has not been released).

public boolean

Returns:

true if the class is read-only, false otherwise.
isClassReadOnly
(Class<?> theClass)

PUBLIC: Checks to see if the specified class is read-only or not in this UnitOfWork.

public boolean
isNestedUnitOfWork()

ADVANCED: Return if this session is a nested unit of work.

public boolean
isObjectRegistered(Object clone)

ADVANCED: Return whether the clone object is already registered.

public Object

Returns:

the registered version for the clone being merged.
mergeClone
(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy.

public Object

Returns:

the registered version for the clone being merged.
mergeCloneWithReferences
(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy.

public Object
newInstance(Class<?> theClass)

PUBLIC: Return a new instance of the class registered in this unit of work.

public void
performFullValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public void
performPartialValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public void
printRegisteredObjects()

PUBLIC: Print the objects in the unit of work.

public Object
refreshAndLockObject(Object object)

PUBLIC: Refresh the attributes of the object and of all of its private parts from the database.

public Object
refreshAndLockObject(Object object, short lockMode)

PUBLIC: Refresh the attributes of the object and of all of its private parts from the database.

public Vector<E>

Returns:

is the clones of the original objects, the return value must be used for editing, editing the original is not allowed in the unit of work.
registerAllObjects
(Collection<E> domainObjects)

PUBLIC: Register the objects with the unit of work.

public Object

Returns:

The clone of the original object, the return value must be used for editing. Editing the original is not allowed in the unit of work.
registerExistingObject
(Object existingObject)

ADVANCED: Register the existing object with the unit of work.

public Object
registerNewObject(Object newObject)

ADVANCED: Register the new object with the unit of work.

public Object

Returns:

the clone of the original object, the return value must be used for editing, ** Editing the original is not allowed in the unit of work. **
registerObject
(Object domainObject)

PUBLIC: Register the object with the unit of work.

public void
release()

Redeclares org.eclipse.persistence.sessions.Session.release.

PUBLIC: Release the unit of work.
public void
removeAllReadOnlyClasses()

PUBLIC: Empties the set of read-only classes.

public void
removeForceUpdateToVersionField(Object cloneFromUOW)

ADVANCED: Remove optimistic read lock from the object See forceUpdateToVersionField(Object)

public void
removeReadOnlyClass(Class<?> theClass)

PUBLIC: Removes a Class from the receiver's set of read-only classes.

public void
revertAndResume()

PUBLIC: Revert all changes made to any registered object.

public Object

Returns:

the object reverted.
revertObject
(Object clone)

PUBLIC: Revert the object's attributes from the parent.

public void
setCommitOrder(UnitOfWork.CommitOrderType order)

ADVANCED: Set the commit order.

public void
setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached)

ADVANCED: By default new objects are not cached until the exist on the database.

public void
setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst)

ADVANCED: By default deletes are performed last in a unit of work.

public void
setShouldThrowConformExceptions(int shouldThrowExceptions)

ADVANCED: Conforming queries can be set to provide different levels of detail about the exceptions they encounter There are two levels: DO_NOT_THROW_CONFORM_EXCEPTIONS = 0; THROW_ALL_CONFORM_EXCEPTIONS = 1;

public void
setValidationLevel(int validationLevel)

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public Object

Returns:

the registered version for the clone being merged.
shallowMergeClone
(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy.

public Object

Returns:

the object reverted.
shallowRevertObject
(Object clone)

PUBLIC: Revert the object's attributes from the parent.

public void
shallowUnregisterObject(Object clone)

ADVANCED: Unregister the object with the unit of work.

public boolean
shouldNewObjectsBeCached()

ADVANCED: By default new objects are not cached until the exist on the database.

public boolean
shouldPerformDeletesFirst()

ADVANCED: By default all objects are inserted and updated in the database before any object is deleted.

public boolean
shouldPerformFullValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public boolean
shouldPerformNoValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public boolean
shouldPerformPartialValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache.

public void
unregisterObject(Object clone)

ADVANCED: Unregister the object with the unit of work.

public void
validateObjectSpace()

ADVANCED: This can be used to help debugging an object-space corruption.

public void
writeChanges()

ADVANCED: Writes all changes now before commit().

Inherited from org.eclipse.persistence.sessions.Session:
acquireHistoricalSessionacquireUnitOfWorkacquireUnitOfWorkaddJPAQueryaddQueryclearIntegrityCheckerclearProfilecontainsQuerycopycopydoesObjectExistdontLogMessagesexecuteNonSelectingCallexecuteNonSelectingSQLexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteQueryexecuteSelectingCallexecuteSQLgetActiveSessiongetActiveUnitOfWorkgetAsOfClausegetClassDescriptorgetClassDescriptorgetClassDescriptorForAliasgetDatasourceLogingetDatasourcePlatformgetDefaultReferenceModegetDescriptorgetDescriptorgetDescriptorForAliasgetDescriptorsgetEventManagergetExceptionHandlergetExternalTransactionControllergetIdgetIdentityMapAccessorgetIntegrityCheckergetJPAQueriesgetLoggetLogingetLogLevelgetLogLevelgetNamegetNextSequenceNumberValuegetPartitioningPolicygetPlatformgetProfilergetProjectgetPropertiesgetPropertygetQueriesgetQuerygetQuerygetSerializergetServerPlatformgetSessionLoghandleExceptionhandleSeverehasDescriptorhasExceptionHandlerhasExternalTransactionControllerisClientSessionisConnectedisDatabaseSessionisDistributedSessionisFinalizersEnabledisInProfileisRemoteSessionisRemoteUnitOfWorkisServerSessionisSessionBrokerisUnitOfWorkloglogMessagereadAllObjectsreadAllObjectsreadAllObjectsreadObjectreadObjectreadObjectreadObjectrefreshObjectremovePropertyremoveQuerysetDefaultReferenceModesetExceptionHandlersetExternalTransactionControllersetIntegrityCheckersetIsFinalizersEnabledsetLogsetLogLevelsetNamesetPartitioningPolicysetProfilersetPropertysetQueryTimeoutDefaultsetQueryTimeoutUnitDefaultsetSerializersetSessionLogshouldLogshouldLogMessagesvalidateCache

Method Detail

addReadOnlyClassback to summary
public void addReadOnlyClass(Class<?> theClass)

PUBLIC: Adds the given Java class to the receiver's set of read-only classes. Cannot be called after objects have been registered in the unit of work.

addReadOnlyClassesback to summary
public void addReadOnlyClasses(Collection<E> classes)

PUBLIC: Adds the classes in the given Vector to the existing set of read-only classes. Cannot be called after objects have been registered in the unit of work.

assignSequenceNumberback to summary
public void assignSequenceNumber(Object object) throws DatabaseException

ADVANCED: Assign sequence number to the object. This allows for an object's id to be assigned before commit. It can be used if the application requires to use the object id before the object exists on the database. Normally all ids are assigned during the commit automatically.

assignSequenceNumbersback to summary
public void assignSequenceNumbers() throws DatabaseException

ADVANCED: Assign sequence numbers to all new objects registered in this unit of work, or any new objects reference by any objects registered. This allows for an object's id to be assigned before commit. It can be used if the application requires to use the object id before the object exists on the database. Normally all ids are assigned during the commit automatically.

beginEarlyTransactionback to summary
public void beginEarlyTransaction() throws DatabaseException

PUBLIC: Tell the unit of work to begin a transaction now. By default the unit of work will begin a transaction at commit time. The default is the recommended approach, however sometimes it is necessary to start the transaction before commit time. When the unit of work commits, this transaction will be committed.

See Also
commit(), release()
commitback to summary
public void commit() throws DatabaseException, OptimisticLockException

PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, and the unit of work will be released. If the commit is successful the unit of work is released, and a new unit of work must be acquired if further changes are desired.

See Also
commitAndResumeOnFailure(), commitAndResume(), release()
commitAndResumeback to summary
public void commitAndResume() throws DatabaseException, OptimisticLockException

PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, and the unit of work will be released. The normal commit releases the unit of work, forcing a new one to be acquired if further changes are desired. The resuming feature allows for the same unit of work (and working copies) to be continued to be used.

See Also
commitAndResumeOnFailure(), commit(), release()
commitAndResumeOnFailureback to summary
public void commitAndResumeOnFailure() throws DatabaseException, OptimisticLockException

PUBLIC: Commit the unit of work to its parent. For a nested unit of work this will merge any changes to its objects with its parents. For a first level unit of work it will commit all changes to its objects to the database as a single transaction. If successful the changes to its objects will be merged to its parent's objects. If the commit fails the database transaction will be rolledback, but the unit of work will remain active. It can then be retried or released. The normal commit failure releases the unit of work, forcing a new one to be acquired if further changes are desired. The resuming feature allows for the same unit of work (and working copies) to be continued to be used if an error occurs. The UnitOfWork will also remain active if the commit is successful.

See Also
commit(), release()
deepMergeCloneback to summary
public Object deepMergeClone(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization or other serialization mechanisms, because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. Everything connected to this object (i.e. the entire object tree where rmiClone is the root) is also merged.

Returns:Object

the registered version for the clone being merged.

See Also
mergeClone(Object), shallowMergeClone(Object)
deepRevertObjectback to summary
public Object deepRevertObject(Object clone)

PUBLIC: Revert the object's attributes from the parent. This reverts everything the object references.

Returns:Object

the object reverted.

See Also
revertObject(Object), shallowRevertObject(Object)
deepUnregisterObjectback to summary
public void deepUnregisterObject(Object clone)

ADVANCED: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. The method should be used carefully because it will delete all the reachable parts.

deleteAllObjectsback to summary
public void deleteAllObjects(Collection<E> domainObjects)

PUBLIC: Delete all of the objects and all of their privately owned parts in the database. Delete operations are delayed in a unit of work until commit.

deleteObjectback to summary
public Object deleteObject(Object domainObject)

PUBLIC: Delete the object and all of their privately owned parts in the database. Delete operations are delayed in a unit of work until commit.

dontPerformValidationback to summary
public void dontPerformValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

forceUpdateToVersionFieldback to summary
public void forceUpdateToVersionField(Object cloneFromUOW, boolean shouldModifyVersionField)

ADVANCED: Set optimistic read lock on the object. This feature is override by normal optimistic lock. when the object is changed in UnitOfWork. The cloneFromUOW must be the clone of from this UnitOfWork and it must implements version locking or timestamp locking. The SQL would look like the followings. If shouldModifyVersionField is true, "UPDATE EMPLOYEE SET VERSION = 2 WHERE EMP_ID = 9 AND VERSION = 1" If shouldModifyVersionField is false, "UPDATE EMPLOYEE SET VERSION = 1 WHERE EMP_ID = 9 AND VERSION = 1"

getCommitOrderback to summary
public UnitOfWork.CommitOrderType getCommitOrder()

ADVANCED: Return the commit order.

getCurrentChangesback to summary
public UnitOfWorkChangeSet getCurrentChanges()

ADVANCED: This method will calculate the changes for the UnitOfWork. Without assigning sequence numbers. This is a computationaly intensive operation and should be avoided unless necessary. A valid changeSet, with sequence numbers can be collected from the UnitOfWork after the commit is complete by calling unitOfWork.getUnitOfWorkChangeSet().

getOriginalVersionOfObjectback to summary
public Object getOriginalVersionOfObject(Object workingClone)

ADVANCED: Return the original version of the object(clone) from the parent's identity map.

getParentback to summary
public AbstractSession getParent()

PUBLIC: Return the parent. This is a unit of work if nested, otherwise a database session or client session.

getReadOnlyClassesback to summary
public Set<E> getReadOnlyClasses()

ADVANCED: Returns the set of read-only classes in this UnitOfWork.

getReferenceback to summary
public Object getReference(Class<?> theClass, Object primaryKey)

Get an instance, whose state may be lazily fetched. If the requested instance does not exist in the database, null is returned, or the object will fail when accessed. The instance will be lazy when it does not exist in the cache, and supports fetch groups.

Parameters
primaryKey:Object

- The primary key of the object, either as a List, singleton, IdClass or an instance of the object.

getUnitOfWorkChangeSetback to summary
public UnitOfWorkChangeSet getUnitOfWorkChangeSet()

ADVANCED: Returns the currentChangeSet from the UnitOfWork. This is only valid after the UnitOfWork has committed successfully

getValidationLevelback to summary
public int getValidationLevel()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

hasChangesback to summary
public boolean hasChanges()

ADVANCED: The Unit of work is capable of preprocessing to determine if any on the clone have been changed. This is computationally expensive and should be avoided on large object graphs.

isActiveback to summary
public boolean isActive()

PUBLIC: Return if the unit of work is active (has not been released).

isClassReadOnlyback to summary
public boolean isClassReadOnly(Class<?> theClass)

PUBLIC: Checks to see if the specified class is read-only or not in this UnitOfWork.

Returns:boolean

true if the class is read-only, false otherwise.

isNestedUnitOfWorkback to summary
public boolean isNestedUnitOfWork()

ADVANCED: Return if this session is a nested unit of work.

isObjectRegisteredback to summary
public boolean isObjectRegistered(Object clone)

ADVANCED: Return whether the clone object is already registered.

mergeCloneback to summary
public Object mergeClone(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged.

Returns:Object

the registered version for the clone being merged.

See Also
shallowMergeClone(Object), deepMergeClone(Object)
mergeCloneWithReferencesback to summary
public Object mergeCloneWithReferences(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or another serialization mechanism), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. The object and its private owned parts are merged. This will include references from this clone to independent objects.

Returns:Object

the registered version for the clone being merged.

See Also
shallowMergeClone(Object), deepMergeClone(Object)
newInstanceback to summary
public Object newInstance(Class<?> theClass)

PUBLIC: Return a new instance of the class registered in this unit of work. This can be used to ensure that new objects are registered correctly.

performFullValidationback to summary
public void performFullValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

performPartialValidationback to summary
public void performPartialValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

printRegisteredObjectsback to summary
public void printRegisteredObjects()

PUBLIC: Print the objects in the unit of work.

refreshAndLockObjectback to summary
public Object refreshAndLockObject(Object object)

PUBLIC: Refresh the attributes of the object and of all of its private parts from the database. The object will be pessimistically locked on the database for the duration of the transaction. If the object is already locked this method will wait until the lock is released. A no wait option is available through setting the lock mode.

See Also
refreshAndLockObject(Object, short)
refreshAndLockObjectback to summary
public Object refreshAndLockObject(Object object, short lockMode)

PUBLIC: Refresh the attributes of the object and of all of its private parts from the database. The object will be pessimistically locked on the database for the duration of the transaction.

Lock Modes: ObjectBuildingQuery.NO_LOCK, LOCK, LOCK_NOWAIT

registerAllObjectsback to summary
public Vector<E> registerAllObjects(Collection<E> domainObjects)

PUBLIC: Register the objects with the unit of work. All newly created root domain objects must be registered to be inserted on commit. Also any existing objects that will be edited and were not read from this unit of work must also be registered. Once registered any changes to the objects will be committed to the database on commit.

Returns:Vector<E>

is the clones of the original objects, the return value must be used for editing, editing the original is not allowed in the unit of work.

registerExistingObjectback to summary
public Object registerExistingObject(Object existingObject)

ADVANCED: Register the existing object with the unit of work. This is a advanced API that can be used if the application can guaranteed the object exists on the database. When registerObject is called the unit of work determines existence through the descriptor's doesExist setting.

Returns:Object

The clone of the original object, the return value must be used for editing. Editing the original is not allowed in the unit of work.

registerNewObjectback to summary
public Object registerNewObject(Object newObject)

ADVANCED: Register the new object with the unit of work. This will register the new object without cloning. Normally the registerObject method should be used for all registration of new and existing objects. This version of the register method can only be used for new objects. This method should only be used if a new object is desired to be registered without cloning.

See Also
registerObject(Object)
registerObjectback to summary
public Object registerObject(Object domainObject)

PUBLIC: Register the object with the unit of work. All newly created root domain objects must be registered to be inserted on commit. Also any existing objects that will be edited and were not read from this unit of work must also be registered. Once registered any changes to the objects will be committed to the database on commit.

Returns:Object

the clone of the original object, the return value must be used for editing, ** Editing the original is not allowed in the unit of work. **

releaseback to summary
public void release()

Redeclares org.eclipse.persistence.sessions.Session.release.

PUBLIC: Release the unit of work. This terminates this unit of work. Because the unit of work operates on its own object space (clones) no work is required. The unit of work should no longer be used or referenced by the application beyond this point so that it can garbage collect.

Annotations
@Override
See Also
commit()
removeAllReadOnlyClassesback to summary
public void removeAllReadOnlyClasses()

PUBLIC: Empties the set of read-only classes. It is illegal to call this method on nested UnitOfWork objects. A nested UnitOfWork cannot have a subset of its parent's set of read-only classes.

removeForceUpdateToVersionFieldback to summary
public void removeForceUpdateToVersionField(Object cloneFromUOW)

ADVANCED: Remove optimistic read lock from the object See forceUpdateToVersionField(Object)

removeReadOnlyClassback to summary
public void removeReadOnlyClass(Class<?> theClass)

PUBLIC: Removes a Class from the receiver's set of read-only classes. It is illegal to try to send this method to a nested UnitOfWork.

revertAndResumeback to summary
public void revertAndResume()

PUBLIC: Revert all changes made to any registered object. Clear all deleted and new objects. Revert should not be confused with release which it the normal compliment to commit. Revert is more similar to commit and resume, however reverts all changes and resumes. If you do not require to resume the unit of work release should be used instead.

See Also
commitAndResume(), release()
revertObjectback to summary
public Object revertObject(Object clone)

PUBLIC: Revert the object's attributes from the parent. This also reverts the object privately-owned parts.

Returns:Object

the object reverted.

See Also
shallowRevertObject(Object), deepRevertObject(Object)
setCommitOrderback to summary
public void setCommitOrder(UnitOfWork.CommitOrderType order)

ADVANCED: Set the commit order.

setShouldNewObjectsBeCachedback to summary
public void setShouldNewObjectsBeCached(boolean shouldNewObjectsBeCached)

ADVANCED: By default new objects are not cached until the exist on the database. Occasionally if mergeClone is used on new objects and is required to allow multiple merges on the same new object, then if the new objects are not cached, each mergeClone will be interpreted as a different new object. By setting new objects to be cached mergeClone can be performed multiple times before commit. New objects cannot be cached unless they have a valid assigned primary key before being registered. New object with non-null invalid primary keys such as 0 or '' can cause problems and should not be used with this option.

setShouldPerformDeletesFirstback to summary
public void setShouldPerformDeletesFirst(boolean shouldPerformDeletesFirst)

ADVANCED: By default deletes are performed last in a unit of work. Sometimes you may want to have the deletes performed before other actions.

setShouldThrowConformExceptionsback to summary
public void setShouldThrowConformExceptions(int shouldThrowExceptions)

ADVANCED: Conforming queries can be set to provide different levels of detail about the exceptions they encounter There are two levels:
DO_NOT_THROW_CONFORM_EXCEPTIONS = 0;
THROW_ALL_CONFORM_EXCEPTIONS = 1;

setValidationLevelback to summary
public void setValidationLevel(int validationLevel)

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

shallowMergeCloneback to summary
public Object shallowMergeClone(Object rmiClone)

PUBLIC: Merge the attributes of the clone into the unit of work copy. This can be used for objects that are returned from the client through RMI serialization (or other serialization mechanisms), because the RMI object will be a clone this will merge its attributes correctly to preserve object identity within the unit of work and record its changes. Only direct attributes are merged.

Returns:Object

the registered version for the clone being merged.

See Also
mergeClone(Object), deepMergeClone(Object)
shallowRevertObjectback to summary
public Object shallowRevertObject(Object clone)

PUBLIC: Revert the object's attributes from the parent. This only reverts the object's direct attributes.

Returns:Object

the object reverted.

See Also
revertObject(Object), deepRevertObject(Object)
shallowUnregisterObjectback to summary
public void shallowUnregisterObject(Object clone)

ADVANCED: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. The method will only unregister the clone, none of its parts.

shouldNewObjectsBeCachedback to summary
public boolean shouldNewObjectsBeCached()

ADVANCED: By default new objects are not cached until the exist on the database. Occasionally if mergeClone is used on new objects and is required to allow multiple merges on the same new object, then if the new objects are not cached, each mergeClone will be interpreted as a different new object. By setting new objects to be cached mergeClone can be performed multiple times before commit. New objects cannot be cached unless they have a valid assigned primary key before being registered. New object with non-null invalid primary keys such as 0 or '' can cause problems and should not be used with this option.

shouldPerformDeletesFirstback to summary
public boolean shouldPerformDeletesFirst()

ADVANCED: By default all objects are inserted and updated in the database before any object is deleted. If this flag is set to true, deletes will be performed before inserts and updates

shouldPerformFullValidationback to summary
public boolean shouldPerformFullValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

shouldPerformNoValidationback to summary
public boolean shouldPerformNoValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

shouldPerformPartialValidationback to summary
public boolean shouldPerformPartialValidation()

ADVANCED: The unit of work performs validations such as, ensuring multiple copies of the same object don't exist in the same unit of work, ensuring deleted objects are not referred after commit, ensures that objects from the parent cache are not referred in the unit of work cache. The level of validation can be increased or decreased for debugging purposes or under advanced situation where the application requires/desires to violate clone identity in the unit of work. It is strongly suggested that clone identity not be violate in the unit of work.

unregisterObjectback to summary
public void unregisterObject(Object clone)

ADVANCED: Unregister the object with the unit of work. This can be used to delete an object that was just created and is not yet persistent. Delete object can also be used, but will result in inserting the object and then deleting it. The method will only unregister private owned parts

validateObjectSpaceback to summary
public void validateObjectSpace()

ADVANCED: This can be used to help debugging an object-space corruption. An object-space corruption is when your application has incorrectly related a clone to an original object. This method will validate that all registered objects are in a correct state and throw an error if not, it will contain the full stack of object references in the error message. If you call this method after each register or change you perform it will pin-point where the error was made.

writeChangesback to summary
public void writeChanges()

ADVANCED: Writes all changes now before commit(). The commit process will begin and all changes will be written out to the datastore, but the datastore transaction will not be committed, nor will changes be merged into the global cache.

A subsequent commit (on UnitOfWork or global transaction) will be required to finalize the commit process.

As the commit process has begun any attempt to register objects, or execute object-level queries will generate an exception. Report queries, non-caching queries, and data read/modify queries are allowed.

On exception any global transaction will be rolled 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.

org.eclipse.persistence.sessions back to summary

public final Enum UnitOfWork.CommitOrderType

extends Enum<UnitOfWork.CommitOrderType>
Class Inheritance

Defines the ordering of updates and deletes of a set of the same entity type during a commit or flush operation. The commit order of entities is defined by their foreign key constraints, and then sorted alphabetically.

By default the commit of a set of the same entity type is ordered by primary key.

Field Summary

Modifier and TypeField and Description
public static final UnitOfWork.CommitOrderType
CHANGES

Updates are ordered by the object's changes, then by id. This can improve batch writing efficiency.

public static final UnitOfWork.CommitOrderType
ID

Updates and deletes are ordered by the object's id. This can help avoid deadlocks on highly concurrent systems.

public static final UnitOfWork.CommitOrderType
NONE

No ordering is done.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static UnitOfWork.CommitOrderType
public static UnitOfWork.CommitOrderType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CHANGESback to summary
public static final UnitOfWork.CommitOrderType CHANGES

Updates are ordered by the object's changes, then by id. This can improve batch writing efficiency.

IDback to summary
public static final UnitOfWork.CommitOrderType ID

Updates and deletes are ordered by the object's id. This can help avoid deadlocks on highly concurrent systems.

NONEback to summary
public static final UnitOfWork.CommitOrderType NONE

No ordering is done.

Constructor Detail

CommitOrderTypeback to summary
private CommitOrderType()

Method Detail

valueOfback to summary
public static UnitOfWork.CommitOrderType valueOf(String name)
valuesback to summary
public static UnitOfWork.CommitOrderType[] values()