Module org.eclipse.persistence.core
Class UnitOfWorkValueHolder<T>
java.lang.Object
org.eclipse.persistence.internal.indirection.DatabaseValueHolder<T>
org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,ValueHolderInterface<T>
,WeavedAttributeValueHolderInterface<T>
,WrappingValueHolder<T>
- Direct Known Subclasses:
UnitOfWorkQueryValueHolder
,UnitOfWorkTransformerValueHolder
public abstract class UnitOfWorkValueHolder<T>
extends DatabaseValueHolder<T>
implements WrappingValueHolder<T>
A UnitOfWorkValueHolder is put in a clone object.
It wraps the value holder in the original object to delay
cloning the attribute in a unit of work until it is
needed by the application.
This value holder is used only in the unit of work.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected ValueHolderInterface
<T> The value holder stored in the backup copy, should not be transient.protected DatabaseMapping
The mapping for the attribute.protected Object
This attribute is used specifically for relationship support.protected UnitOfWorkImpl
These cannot be transient because they are required for a remote unit of work.protected String
protected Object
protected ValueHolderInterface
<T> The value holder in the original object.protected ObjID
Fields inherited from class org.eclipse.persistence.internal.indirection.DatabaseValueHolder
isCoordinatedWithProperty, isInstantiated, row, session, value
Fields inherited from interface org.eclipse.persistence.indirection.ValueHolderInterface
shouldToStringInstantiate
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
UnitOfWorkValueHolder
(ValueHolderInterface<T> attributeValue, Object clone, DatabaseMapping mapping, UnitOfWorkImpl unitOfWork) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Object
buildBackupCloneFor
(Object cloneAttributeValue) Backup the clone attribute value.abstract T
buildCloneFor
(Object originalAttributeValue) Clone the original attribute value.protected ValueHolderInterface
<T> protected Object
protected UnitOfWorkImpl
protected String
protected Object
protected UnitOfWorkImpl
protected T
This is used for a remote unit of work.Returns the valueholder that is wrapped by this ValueHolderreturns wrapped ValueHolder ObjID if availableprotected T
Get the value from the wrapped value holder, instantiating it if necessary, and clone it.instantiateForUnitOfWorkValueHolder
(UnitOfWorkValueHolder<T> unitOfWorkValueHolder) Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).protected T
a.k.a getValueFromWrappedValueholder.boolean
INTERNAL: Answers if this valueholder is easy to instantiate.boolean
INTERNAL: Answers if this valueholder is a pessimistic locking one.boolean
Used to determine if this is a remote uow value holder that was serialized to the server.void
releaseWrappedValueHolder
(AbstractSession targetSession) Releases a wrapped valueholder privately owned by a particular unit of work.protected void
Reset all the fields that are not needed after instantiation.void
setBackupValueHolder
(ValueHolderInterface<T> backupValueHolder) protected void
setMapping
(DatabaseMapping mapping) protected void
setRelationshipSourceObject
(Object relationshipSourceObject) protected void
setRemoteUnitOfWork
(UnitOfWorkImpl remoteUnitOfWork) protected void
setSourceAttributeName
(String name) protected void
setSourceObject
(Object sourceObject) protected void
setWrappedValueHolder
(DatabaseValueHolder<T> valueHolder) boolean
INTERNAL: Return if add/remove should trigger instantiation or avoid.Methods inherited from class org.eclipse.persistence.internal.indirection.DatabaseValueHolder
clone, getRow, getSession, getValue, getValue, isCoordinatedWithProperty, isInstantiated, isNewlyWeavedValueHolder, isTransactionalValueHolder, postInstantiate, privilegedSetValue, setInstantiated, setIsCoordinatedWithProperty, setIsNewlyWeavedValueHolder, setRow, setSession, setUninstantiated, setValue, toString
-
Field Details
-
wrappedValueHolder
The value holder in the original object. -
mapping
The mapping for the attribute. -
backupValueHolder
The value holder stored in the backup copy, should not be transient. -
remoteUnitOfWork
These cannot be transient because they are required for a remote unit of work. When the remote uow is serialized to the server to be committed, these are used to reconstruct the value holder on the server. They should be null for non-remote sessions. -
sourceObject
-
relationshipSourceObject
This attribute is used specifically for relationship support. It mimics the sourceObject attribute which is used for RemoteValueholder -
sourceAttributeName
-
wrappedValueHolderRemoteID
-
-
Constructor Details
-
UnitOfWorkValueHolder
protected UnitOfWorkValueHolder() -
UnitOfWorkValueHolder
protected UnitOfWorkValueHolder(ValueHolderInterface<T> attributeValue, Object clone, DatabaseMapping mapping, UnitOfWorkImpl unitOfWork)
-
-
Method Details
-
buildBackupCloneFor
Backup the clone attribute value. -
buildCloneFor
Clone the original attribute value. -
getBackupValueHolder
-
getMapping
-
getRemoteUnitOfWork
-
getSourceAttributeName
-
getSourceObject
-
getRelationshipSourceObject
-
getUnitOfWork
-
getValueFromServerObject
This is used for a remote unit of work. If the value holder is sent back to the server uninstantiated and it needs to be instantiated, then we must find the original object and get the appropriate attribute from it. -
instantiateImpl
a.k.a getValueFromWrappedValueholder. The old name is no longer correct, as query based valueholders are now sometimes triggered directly without triggering the underlying valueholder. -
isEasilyInstantiated
public boolean isEasilyInstantiated()INTERNAL: Answers if this valueholder is easy to instantiate.- Overrides:
isEasilyInstantiated
in classDatabaseValueHolder<T>
- Returns:
- true if getValue() won't trigger a database read.
-
isPessimisticLockingValueHolder
public boolean isPessimisticLockingValueHolder()INTERNAL: Answers if this valueholder is a pessimistic locking one. Such valueholders are special in that they can be triggered multiple times by different UnitsOfWork. Each time a lock query will be issued. Hence even if instantiated it may have to be instantiated again, and once instantatiated all fields can not be reset.- Specified by:
isPessimisticLockingValueHolder
in classDatabaseValueHolder<T>
-
getWrappedValueHolder
Description copied from interface:WrappingValueHolder
Returns the valueholder that is wrapped by this ValueHolder- Specified by:
getWrappedValueHolder
in interfaceWrappingValueHolder<T>
- Overrides:
getWrappedValueHolder
in classDatabaseValueHolder<T>
-
getWrappedValueHolderRemoteID
returns wrapped ValueHolder ObjID if available -
isSerializedRemoteUnitOfWorkValueHolder
public boolean isSerializedRemoteUnitOfWorkValueHolder()Used to determine if this is a remote uow value holder that was serialized to the server. It has no reference to its wrapper value holder, so must find its original object to be able to instantiate.- Overrides:
isSerializedRemoteUnitOfWorkValueHolder
in classDatabaseValueHolder<T>
-
instantiate
Get the value from the wrapped value holder, instantiating it if necessary, and clone it.- Specified by:
instantiate
in classDatabaseValueHolder<T>
-
instantiateForUnitOfWorkValueHolder
Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).When in transaction and/or for pessimistic locking the UnitOfWorkValueHolder needs to be triggered directly without triggering the wrapped valueholder. However only the wrapped valueholder knows how to trigger the indirection, i.e. it may be a batchValueHolder, and it stores all the info like the row and the query.
- Specified by:
instantiateForUnitOfWorkValueHolder
in classDatabaseValueHolder<T>
-
releaseWrappedValueHolder
Releases a wrapped valueholder privately owned by a particular unit of work.When unit of work clones are built directly from rows no object in the shared cache points to this valueholder, so it can store the unit of work as its session. However once that UnitOfWork commits and the valueholder is merged into the shared cache, the session needs to be reset to the root session, ie. the server session.
- Overrides:
releaseWrappedValueHolder
in classDatabaseValueHolder<T>
-
resetFields
protected void resetFields()Reset all the fields that are not needed after instantiation.- Overrides:
resetFields
in classDatabaseValueHolder<T>
-
setBackupValueHolder
-
setMapping
-
setRemoteUnitOfWork
-
setSourceAttributeName
-
setSourceObject
-
setRelationshipSourceObject
-
setWrappedValueHolder
-
shouldAllowInstantiationDeferral
public boolean shouldAllowInstantiationDeferral()INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking.- Specified by:
shouldAllowInstantiationDeferral
in interfaceWeavedAttributeValueHolderInterface<T>
- Overrides:
shouldAllowInstantiationDeferral
in classDatabaseValueHolder<T>
-