Top Description Fields Constructors Methods
org.eclipse.persistence.internal.indirection

public abstract Class DatabaseValueHolder<T>

extends Object
implements WeavedAttributeValueHolderInterface<T>, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface, org.eclipse.persistence.indirection.ValueHolderInterface
Known Direct Subclasses
org.eclipse.persistence.internal.indirection.ProtectedValueHolder, org.eclipse.persistence.internal.indirection.QueryBasedValueHolder, org.eclipse.persistence.internal.indirection.TransformerBasedValueHolder, org.eclipse.persistence.internal.indirection.UnitOfWorkValueHolder, org.eclipse.persistence.internal.sessions.remote.RemoteValueHolder, org.eclipse.persistence.internal.indirection.BackupValueHolder, org.eclipse.persistence.internal.indirection.CacheBasedValueHolder
Imports
java.io.Serializable, org.eclipse.persistence.exceptions.DatabaseException, org.eclipse.persistence.indirection.ValueHolderInterface, .WeavedAttributeValueHolderInterface, org.eclipse.persistence.internal.helper.Helper, org.eclipse.persistence.internal.localization.ToStringLocalization, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .UnitOfWorkImpl

DatabaseValueHolder wraps a database-stored object and implements behavior to access it. The object is read only once from database after which is cached for faster access.
Author
Dorin Sandu
See Also
ValueHolderInterface

Field Summary

Modifier and TypeField and Description
protected boolean
isCoordinatedWithProperty

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 known

protected volatile boolean
isInstantiated

Indicates whether the object has been read from the database or not.

protected AbstractRecord
row

Stores the row representation of the object.

protected transient AbstractSession
session

Stores the session for the database that contains the object.

protected volatile T
value

Stores the object after it is read from the database.

Constructor Summary

AccessConstructor and Description
protected
DatabaseValueHolder()

Default constructor.

Method Summary

Modifier and TypeMethod and Description
public Object
clone()

Overrides java.lang.Object.clone.

Implements org.eclipse.persistence.indirection.ValueHolderInterface.clone.

PUBLIC: Copy the value holder (but not its' reference, shallow).
public AbstractRecord
getRow()

Return the row.

public AbstractSession
getSession()

Return the session.

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

public ValueHolderInterface<?>
protected abstract T
instantiate()

Instantiate the object.

public abstract T
instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder<T> unitOfWorkValueHolder)

Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).

public boolean
isCoordinatedWithProperty()

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.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
public boolean

Returns:

true if getValue() won't trigger a database read.
isEasilyInstantiated
()

INTERNAL: Answers if this valueholder is easy to instantiate.

public boolean
isInstantiated()

Implements org.eclipse.persistence.indirection.ValueHolderInterface.isInstantiated.

Return a boolean indicating whether the object has been read from the database or not.
public boolean
isNewlyWeavedValueHolder()

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.isNewlyWeavedValueHolder.

This method is used as part of the implementation of WeavedAttributeValueHolderInterface.
public abstract boolean
isPessimisticLockingValueHolder()

Answers if this valueholder is a pessimistic locking one.

public boolean
isSerializedRemoteUnitOfWorkValueHolder()

Used to determine if this is a remote uow value holder that was serialized to the server.

protected boolean
isTransactionalValueHolder()

Answers if this valueholder is referenced only by a UnitOfWork valueholder.

public void
postInstantiate()

INTERNAL: Run any extra code required after the valueholder instantiates

public void
privilegedSetValue(T value)

Set the object.

public void
releaseWrappedValueHolder(AbstractSession targetSession)

Releases a wrapped valueholder privately owned by a particular unit of work.

protected void
resetFields()

Reset all the fields that are not needed after instantiation.

public void
setInstantiated()

Set the instantiated flag to true.

public void
setIsCoordinatedWithProperty(boolean coordinated)

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.setIsCoordinatedWithProperty.

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
public void
setIsNewlyWeavedValueHolder(boolean isNew)

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.setIsNewlyWeavedValueHolder.

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.
public void
setRow(AbstractRecord row)

Set the row.

public void
setSession(AbstractSession session)

Set the session.

public void
setUninstantiated()

Set the instantiated flag to false.

public void
public boolean
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
equalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

isCoordinatedWithPropertyback to summary
protected boolean isCoordinatedWithProperty

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 known

isInstantiatedback to summary
protected volatile boolean isInstantiated

Indicates whether the object has been read from the database or not.

rowback to summary
protected AbstractRecord row

Stores the row representation of the object.

sessionback to summary
protected transient AbstractSession session

Stores the session for the database that contains the object.

valueback to summary
protected volatile T value

Stores the object after it is read from the database.

Constructor Detail

DatabaseValueHolderback to summary
protected DatabaseValueHolder()

Default constructor.

Method Detail

cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Implements org.eclipse.persistence.indirection.ValueHolderInterface.clone.

Doc from org.eclipse.persistence.indirection.ValueHolderInterface.clone.

PUBLIC: Copy the value holder (but not its' reference, shallow).

Returns:Object

Doc from java.lang.Object.clone.

a clone of this instance.

Annotations
@Override
getRowback to summary
public AbstractRecord getRow()

Return the row.

getSessionback to summary
public AbstractSession getSession()

Return the session.

getValueback to summary
public T getValue()

Implements org.eclipse.persistence.indirection.ValueHolderInterface.getValue.

Return the object.

Annotations
@Override
getValueback to summary
public T 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.

getWrappedValueHolderback to summary
public ValueHolderInterface<?> getWrappedValueHolder()
instantiateback to summary
protected abstract T instantiate() throws DatabaseException

Instantiate the object.

instantiateForUnitOfWorkValueHolderback to summary
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

isCoordinatedWithPropertyback to summary
public boolean isCoordinatedWithProperty()

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.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

Annotations
@Override
isEasilyInstantiatedback to summary
public boolean isEasilyInstantiated()

INTERNAL: Answers if this valueholder is easy to instantiate.

Returns:boolean

true if getValue() won't trigger a database read.

isInstantiatedback to summary
public boolean isInstantiated()

Implements org.eclipse.persistence.indirection.ValueHolderInterface.isInstantiated.

Return a boolean indicating whether the object has been read from the database or not.

Annotations
@Override
isNewlyWeavedValueHolderback to summary
public boolean isNewlyWeavedValueHolder()

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.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.

Annotations
@Override
isPessimisticLockingValueHolderback to summary
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

isSerializedRemoteUnitOfWorkValueHolderback to summary
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.

isTransactionalValueHolderback to summary
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.

postInstantiateback to summary
public void postInstantiate()

INTERNAL: Run any extra code required after the valueholder instantiates

See Also
QueryBasedValueHolder
privilegedSetValueback to summary
public void privilegedSetValue(T value)

Set the object. This is used only by the privileged methods. One must be very careful in using this method.

releaseWrappedValueHolderback to summary
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.

resetFieldsback to summary
protected void resetFields()

Reset all the fields that are not needed after instantiation.

setInstantiatedback to summary
public void setInstantiated()

Set the instantiated flag to true.

setIsCoordinatedWithPropertyback to summary
public void setIsCoordinatedWithProperty(boolean coordinated)

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.setIsCoordinatedWithProperty.

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

Annotations
@Override
setIsNewlyWeavedValueHolderback to summary
public void setIsNewlyWeavedValueHolder(boolean isNew)

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.setIsNewlyWeavedValueHolder.

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.

Annotations
@Override
setRowback to summary
public void setRow(AbstractRecord row)

Set the row.

setSessionback to summary
public void setSession(AbstractSession session)

Set the session.

setUninstantiatedback to summary
public void setUninstantiated()

Set the instantiated flag to false.

setValueback to summary
public void setValue(T value)

Implements org.eclipse.persistence.indirection.ValueHolderInterface.setValue.

Set the object.

Annotations
@Override
shouldAllowInstantiationDeferralback to summary
public boolean shouldAllowInstantiationDeferral()

Implements org.eclipse.persistence.indirection.WeavedAttributeValueHolderInterface.shouldAllowInstantiationDeferral.

INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override