Class UnitOfWorkValueHolder
- java.lang.Object
-
- org.eclipse.persistence.internal.indirection.DatabaseValueHolder
-
- org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,ValueHolderInterface,WeavedAttributeValueHolderInterface,WrappingValueHolder
- Direct Known Subclasses:
UnitOfWorkQueryValueHolder,UnitOfWorkTransformerValueHolder
public abstract class UnitOfWorkValueHolder extends DatabaseValueHolder implements WrappingValueHolder
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.- Author:
- Sati
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ValueHolderInterfacebackupValueHolderThe value holder stored in the backup copy, should not be transient.protected DatabaseMappingmappingThe mapping for the attribute.protected java.lang.ObjectrelationshipSourceObjectThis attribute is used specifically for relationship support.protected UnitOfWorkImplremoteUnitOfWorkThese cannot be transient because they are required for a remote unit of work.protected java.lang.StringsourceAttributeNameprotected java.lang.ObjectsourceObjectprotected ValueHolderInterfacewrappedValueHolderThe value holder in the original object.protected java.rmi.server.ObjIDwrappedValueHolderRemoteID-
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
Constructors Modifier Constructor Description protectedUnitOfWorkValueHolder()protectedUnitOfWorkValueHolder(ValueHolderInterface attributeValue, java.lang.Object clone, DatabaseMapping mapping, UnitOfWorkImpl unitOfWork)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract java.lang.ObjectbuildBackupCloneFor(java.lang.Object cloneAttributeValue)Backup the clone attribute value.abstract java.lang.ObjectbuildCloneFor(java.lang.Object originalAttributeValue)Clone the original attribute value.protected ValueHolderInterfacegetBackupValueHolder()DatabaseMappinggetMapping()protected java.lang.ObjectgetRelationshipSourceObject()protected UnitOfWorkImplgetRemoteUnitOfWork()protected java.lang.StringgetSourceAttributeName()protected java.lang.ObjectgetSourceObject()protected UnitOfWorkImplgetUnitOfWork()protected java.lang.ObjectgetValueFromServerObject()This is used for a remote unit of work.ValueHolderInterfacegetWrappedValueHolder()Returns the valueholder that is wrapped by this ValueHolderjava.rmi.server.ObjIDgetWrappedValueHolderRemoteID()returns wrapped ValueHolder ObjID if availableprotected java.lang.Objectinstantiate()Get the value from the wrapped value holder, instantiating it if necessary, and clone it.java.lang.ObjectinstantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder unitOfWorkValueHolder)Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).protected java.lang.ObjectinstantiateImpl()a.k.a getValueFromWrappedValueholder.booleanisEasilyInstantiated()INTERNAL: Answers if this valueholder is easy to instantiate.booleanisPessimisticLockingValueHolder()INTERNAL: Answers if this valueholder is a pessimistic locking one.booleanisSerializedRemoteUnitOfWorkValueHolder()Used to determine if this is a remote uow value holder that was serialized to the server.voidreleaseWrappedValueHolder(AbstractSession targetSession)Releases a wrapped valueholder privately owned by a particular unit of work.protected voidresetFields()Reset all the fields that are not needed after instantiation.voidsetBackupValueHolder(ValueHolderInterface backupValueHolder)protected voidsetMapping(DatabaseMapping mapping)protected voidsetRelationshipSourceObject(java.lang.Object relationshipSourceObject)protected voidsetRemoteUnitOfWork(UnitOfWorkImpl remoteUnitOfWork)protected voidsetSourceAttributeName(java.lang.String name)protected voidsetSourceObject(java.lang.Object sourceObject)protected voidsetWrappedValueHolder(DatabaseValueHolder valueHolder)booleanshouldAllowInstantiationDeferral()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 Detail
-
wrappedValueHolder
protected transient ValueHolderInterface wrappedValueHolder
The value holder in the original object.
-
mapping
protected transient DatabaseMapping mapping
The mapping for the attribute.
-
backupValueHolder
protected ValueHolderInterface backupValueHolder
The value holder stored in the backup copy, should not be transient.
-
remoteUnitOfWork
protected UnitOfWorkImpl 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
protected java.lang.Object sourceObject
-
relationshipSourceObject
protected transient java.lang.Object relationshipSourceObject
This attribute is used specifically for relationship support. It mimics the sourceObject attribute which is used for RemoteValueholder
-
sourceAttributeName
protected java.lang.String sourceAttributeName
-
wrappedValueHolderRemoteID
protected java.rmi.server.ObjID wrappedValueHolderRemoteID
-
-
Constructor Detail
-
UnitOfWorkValueHolder
protected UnitOfWorkValueHolder()
-
UnitOfWorkValueHolder
protected UnitOfWorkValueHolder(ValueHolderInterface attributeValue, java.lang.Object clone, DatabaseMapping mapping, UnitOfWorkImpl unitOfWork)
-
-
Method Detail
-
buildBackupCloneFor
protected abstract java.lang.Object buildBackupCloneFor(java.lang.Object cloneAttributeValue)
Backup the clone attribute value.
-
buildCloneFor
public abstract java.lang.Object buildCloneFor(java.lang.Object originalAttributeValue)
Clone the original attribute value.
-
getBackupValueHolder
protected ValueHolderInterface getBackupValueHolder()
-
getMapping
public DatabaseMapping getMapping()
-
getRemoteUnitOfWork
protected UnitOfWorkImpl getRemoteUnitOfWork()
-
getSourceAttributeName
protected java.lang.String getSourceAttributeName()
-
getSourceObject
protected java.lang.Object getSourceObject()
-
getRelationshipSourceObject
protected java.lang.Object getRelationshipSourceObject()
-
getUnitOfWork
protected UnitOfWorkImpl getUnitOfWork()
-
getValueFromServerObject
protected java.lang.Object 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
protected java.lang.Object 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:
isEasilyInstantiatedin classDatabaseValueHolder- 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:
isPessimisticLockingValueHolderin classDatabaseValueHolder
-
getWrappedValueHolder
public ValueHolderInterface getWrappedValueHolder()
Description copied from interface:WrappingValueHolderReturns the valueholder that is wrapped by this ValueHolder- Specified by:
getWrappedValueHolderin interfaceWrappingValueHolder- Overrides:
getWrappedValueHolderin classDatabaseValueHolder
-
getWrappedValueHolderRemoteID
public java.rmi.server.ObjID 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:
isSerializedRemoteUnitOfWorkValueHolderin classDatabaseValueHolder
-
instantiate
protected java.lang.Object instantiate()
Get the value from the wrapped value holder, instantiating it if necessary, and clone it.- Specified by:
instantiatein classDatabaseValueHolder
-
instantiateForUnitOfWorkValueHolder
public java.lang.Object instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder unitOfWorkValueHolder)
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:
instantiateForUnitOfWorkValueHolderin classDatabaseValueHolder
-
releaseWrappedValueHolder
public void releaseWrappedValueHolder(AbstractSession targetSession)
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:
releaseWrappedValueHolderin classDatabaseValueHolder
-
resetFields
protected void resetFields()
Reset all the fields that are not needed after instantiation.- Overrides:
resetFieldsin classDatabaseValueHolder
-
setBackupValueHolder
public void setBackupValueHolder(ValueHolderInterface backupValueHolder)
-
setMapping
protected void setMapping(DatabaseMapping mapping)
-
setRemoteUnitOfWork
protected void setRemoteUnitOfWork(UnitOfWorkImpl remoteUnitOfWork)
-
setSourceAttributeName
protected void setSourceAttributeName(java.lang.String name)
-
setSourceObject
protected void setSourceObject(java.lang.Object sourceObject)
-
setRelationshipSourceObject
protected void setRelationshipSourceObject(java.lang.Object relationshipSourceObject)
-
setWrappedValueHolder
protected void setWrappedValueHolder(DatabaseValueHolder valueHolder)
-
shouldAllowInstantiationDeferral
public boolean shouldAllowInstantiationDeferral()
INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking.- Specified by:
shouldAllowInstantiationDeferralin interfaceWeavedAttributeValueHolderInterface- Overrides:
shouldAllowInstantiationDeferralin classDatabaseValueHolder
-
-