Class DatabaseValueHolder<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,ValueHolderInterface<T>
,WeavedAttributeValueHolderInterface<T>
- Direct Known Subclasses:
BackupValueHolder
,CacheBasedValueHolder
,ProtectedValueHolder
,QueryBasedValueHolder
,RemoteValueHolder
,TransformerBasedValueHolder
,UnitOfWorkValueHolder
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
The variable below is used as part of the implementation of WeavedAttributeValueHolderInterface It is used to track whether a valueholder that has been weaved into a class is coordinated with the underlying property Set internally in EclipseLink when the state of coordination between a weaved valueholder and the underlying property is knownprotected boolean
Indicates whether the object has been read from the database or not.protected AbstractRecord
Stores the row representation of the object.protected AbstractSession
Stores the session for the database that contains the object.protected T
Stores the object after it is read from the database.Fields inherited from interface org.eclipse.persistence.indirection.ValueHolderInterface
shouldToStringInstantiate
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclone()
PUBLIC: Copy the value holder (but not its' reference, shallow).getRow()
Return the row.Return the session.getValue()
Return the object.getValue
(UnitOfWorkImpl uow) Process against the UOW and attempt to load a local copy before going to the shared cache If null is returned then the calling UOW will instantiate as normal.protected abstract T
Instantiate the object.abstract T
instantiateForUnitOfWorkValueHolder
(UnitOfWorkValueHolder<T> unitOfWorkValueHolder) Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).boolean
This method is used as part of the implementation of WeavedAttributeValueHolderInterface It is used to check whether a valueholder that has been weaved into a class is coordinated with the underlying propertyboolean
INTERNAL: Answers if this valueholder is easy to instantiate.boolean
Return a boolean indicating whether the object has been read from the database or not.boolean
This method is used as part of the implementation of WeavedAttributeValueHolderInterface.abstract boolean
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.protected boolean
Answers if this valueholder is referenced only by a UnitOfWork valueholder.void
INTERNAL: Run any extra code required after the valueholder instantiatesvoid
privilegedSetValue
(T value) Set the object.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
Set the instantiated flag to true.void
setIsCoordinatedWithProperty
(boolean coordinated) This method is used as part of the implementation of WeavedAttributeValueHolderInterface It is used internally by EclipseLink to set whether a valueholder that has been weaved into a class is coordinated with the underlying propertyvoid
setIsNewlyWeavedValueHolder
(boolean isNew) This method is used as part of the implementation of WeavedAttributeValueHolderInterface A DatabaseValueHolder is set up by EclipseLink and will never be a newly weaved valueholder As a result, this method is stubbed out.void
setRow
(AbstractRecord row) Set the row.void
setSession
(AbstractSession session) Set the session.void
Set the instantiated flag to false.void
Set the object.boolean
INTERNAL: Return if add/remove should trigger instantiation or avoid.toString()
-
Field Details
-
value
Stores the object after it is read from the database. -
isInstantiated
protected volatile boolean isInstantiatedIndicates whether the object has been read from the database or not. -
session
Stores the session for the database that contains the object. -
row
Stores the row representation of the object. -
isCoordinatedWithProperty
protected boolean isCoordinatedWithPropertyThe variable below is used as part of the implementation of WeavedAttributeValueHolderInterface It is used to track whether a valueholder that has been weaved into a class is coordinated with the underlying property Set internally in EclipseLink when the state of coordination between a weaved valueholder and the underlying property is known
-
-
Constructor Details
-
DatabaseValueHolder
protected DatabaseValueHolder()Default constructor.
-
-
Method Details
-
clone
Description copied from interface:ValueHolderInterface
PUBLIC: Copy the value holder (but not its' reference, shallow).- Specified by:
clone
in interfaceValueHolderInterface<T>
- Overrides:
clone
in classObject
-
getRow
Return the row. -
getSession
Return the session. -
getWrappedValueHolder
-
getValue
Return the object.- Specified by:
getValue
in interfaceValueHolderInterface<T>
-
getValue
Process against the UOW and attempt to load a local copy before going to the shared cache If null is returned then the calling UOW will instantiate as normal. -
instantiate
Instantiate the object.- Throws:
DatabaseException
-
instantiateForUnitOfWorkValueHolder
public abstract T instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder<T> 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. Note: Implementations of this method are not necessarily thread-safe. They must be used in a synchronized manner
-
isCoordinatedWithProperty
public boolean isCoordinatedWithProperty()This method is used as part of the implementation of WeavedAttributeValueHolderInterface It is used to check whether a valueholder that has been weaved into a class is coordinated with the underlying property- Specified by:
isCoordinatedWithProperty
in interfaceWeavedAttributeValueHolderInterface<T>
-
isNewlyWeavedValueHolder
public boolean isNewlyWeavedValueHolder()This method is used as part of the implementation of WeavedAttributeValueHolderInterface. A DatabaseValueHolder is set up by TopLink and will never be a newly weaved valueholder. As a result, this method is stubbed out.- Specified by:
isNewlyWeavedValueHolder
in interfaceWeavedAttributeValueHolderInterface<T>
-
isEasilyInstantiated
public boolean isEasilyInstantiated()INTERNAL: Answers if this valueholder is easy to instantiate.- Returns:
- true if getValue() won't trigger a database read.
-
isInstantiated
public boolean isInstantiated()Return a boolean indicating whether the object has been read from the database or not.- Specified by:
isInstantiated
in interfaceValueHolderInterface<T>
-
isPessimisticLockingValueHolder
public abstract boolean isPessimisticLockingValueHolder()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 instantiated all fields can not be reset. Note: Implementations of this method are not necessarily thread-safe. They must be used in a synchronizaed manner -
isTransactionalValueHolder
protected boolean isTransactionalValueHolder()Answers if this valueholder is referenced only by a UnitOfWork valueholder. I.e. it was built in valueFromRow which was called by buildCloneFromRow.Sometimes in transaction a UnitOfWork clone, and all valueholders, are built directly from the row; however a UnitOfWorkValueHolder does not know how to instantiate itself so wraps this which does.
On a successful merge must be released to the session cache with releaseWrappedValueHolder.
-
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. -
postInstantiate
public void postInstantiate()INTERNAL: Run any extra code required after the valueholder instantiates- See Also:
-
privilegedSetValue
Set the object. This is used only by the privileged methods. One must be very careful in using this method. -
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.
-
resetFields
protected void resetFields()Reset all the fields that are not needed after instantiation. -
setIsCoordinatedWithProperty
public void setIsCoordinatedWithProperty(boolean coordinated) This method is used as part of the implementation of WeavedAttributeValueHolderInterface It is used internally by EclipseLink to set whether a valueholder that has been weaved into a class is coordinated with the underlying property- Specified by:
setIsCoordinatedWithProperty
in interfaceWeavedAttributeValueHolderInterface<T>
-
setIsNewlyWeavedValueHolder
public void setIsNewlyWeavedValueHolder(boolean isNew) This method is used as part of the implementation of WeavedAttributeValueHolderInterface A DatabaseValueHolder is set up by EclipseLink and will never be a newly weaved valueholder As a result, this method is stubbed out.- Specified by:
setIsNewlyWeavedValueHolder
in interfaceWeavedAttributeValueHolderInterface<T>
-
setInstantiated
public void setInstantiated()Set the instantiated flag to true. -
setRow
Set the row. -
setSession
Set the session. -
setUninstantiated
public void setUninstantiated()Set the instantiated flag to false. -
setValue
Set the object.- Specified by:
setValue
in interfaceValueHolderInterface<T>
-
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>
-
toString
-