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

public Class QueryBasedValueHolder<T>

extends DatabaseValueHolder<T>
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.internal.indirection.BatchValueHolder, org.eclipse.persistence.internal.indirection.EISOneToManyQueryBasedValueHolder
Imports
org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.exceptions.DatabaseException, .ValidationException, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, .UnitOfWorkImpl, org.eclipse.persistence.mappings.AttributeAccessor, .DatabaseMapping, .ForeignReferenceMapping, org.eclipse.persistence.queries.ObjectBuildingQuery, .ObjectLevelReadQuery, .ReadQuery

QueryBasedValueHolder wraps a database-stored object and implements behavior to access it. The object is read from the database by invoking a user-specified query.
Author
Dorin Sandu
See Also
ObjectLevelReadQuery

Field Summary

Modifier and TypeField and Description
protected transient ReadQuery
query

Stores the query to be executed.

protected Integer
protected transient Object
Inherited from org.eclipse.persistence.internal.indirection.DatabaseValueHolder:
isCoordinatedWithPropertyisInstantiatedrowsessionvalue

Constructor Summary

AccessConstructor and Description
protected
public
QueryBasedValueHolder(ReadQuery query, AbstractRecord row, AbstractSession session)

Initialize the query-based value holder.

public
QueryBasedValueHolder(ReadQuery query, Object sourceObject, AbstractRecord row, AbstractSession session)

Initialize the query-based value holder.

Method Summary

Modifier and TypeMethod and Description
public ReadQuery
getQuery()

Return the query.

public Integer
getRefreshCascadePolicy()

INTERNAL: Returns the refresh cascade policy that was set on the query that was used to instantiate the valueholder a null value means that a non refresh query was used.

public T
getValue(UnitOfWorkImpl uow)

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.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.
protected T
protected T
instantiate(AbstractSession session)

Instantiate the object by executing the query on the session.

public T
instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder<T> unitOfWorkValueHolder)

Implements abstract org.eclipse.persistence.internal.indirection.DatabaseValueHolder.instantiateForUnitOfWorkValueHolder.

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

Implements abstract org.eclipse.persistence.internal.indirection.DatabaseValueHolder.isPessimisticLockingValueHolder.

INTERNAL: Answers if this valueholder is a pessimistic locking one.
public void
postInstantiate()

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.postInstantiate.

INTERNAL: Run any extra code required after the valueholder instantiates For query based VH, we notify the cache that the valueholder has been triggered
public void
releaseWrappedValueHolder(AbstractSession targetSession)

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.releaseWrappedValueHolder.

Releases a wrapped valueholder privately owned by a particular unit of work.
protected void
resetFields()

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.resetFields.

Reset all the fields that are not needed after instantiation.
protected void
setQuery(ReadQuery theQuery)

Set the query.

public void
setRefreshCascadePolicy(Integer refreshCascadePolicy)

INTERNAL:

public void
setSourceObject(Object sourceObject)

Inherited from org.eclipse.persistence.internal.indirection.DatabaseValueHolder:
clonegetRowgetSessiongetValuegetWrappedValueHolderisCoordinatedWithPropertyisEasilyInstantiatedisInstantiatedisNewlyWeavedValueHolderisSerializedRemoteUnitOfWorkValueHolderisTransactionalValueHolderprivilegedSetValuesetInstantiatedsetIsCoordinatedWithPropertysetIsNewlyWeavedValueHoldersetRowsetSessionsetUninstantiatedsetValueshouldAllowInstantiationDeferraltoString

Field Detail

queryback to summary
protected transient ReadQuery query

Stores the query to be executed.

refreshCascadeback to summary
protected Integer refreshCascade
sourceObjectback to summary
protected transient Object sourceObject

Constructor Detail

QueryBasedValueHolderback to summary
protected QueryBasedValueHolder()
QueryBasedValueHolderback to summary
public QueryBasedValueHolder(ReadQuery query, AbstractRecord row, AbstractSession session)

Initialize the query-based value holder.

QueryBasedValueHolderback to summary
public QueryBasedValueHolder(ReadQuery query, Object sourceObject, AbstractRecord row, AbstractSession session)

Initialize the query-based value holder.

Method Detail

getQueryback to summary
public ReadQuery getQuery()

Return the query. The query for a QueryBasedValueHolder is constructed dynamically based on the original query on the parent object and the mapping configuration. If modifying a query the developer must be careful not to change the results returned as that may cause the application to see incorrect results.

getRefreshCascadePolicyback to summary
public Integer getRefreshCascadePolicy()

INTERNAL: Returns the refresh cascade policy that was set on the query that was used to instantiate the valueholder a null value means that a non refresh query was used.

getValueback to summary
public T getValue(UnitOfWorkImpl uow)

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.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.

Annotations
@Override
@SuppressWarnings:unchecked
instantiateback to summary
protected T instantiate() throws DatabaseException

Implements abstract org.eclipse.persistence.internal.indirection.DatabaseValueHolder.instantiate.

Doc from org.eclipse.persistence.internal.indirection.DatabaseValueHolder.instantiate.

Instantiate the object.

Annotations
@Override
instantiateback to summary
protected T instantiate(AbstractSession session) throws DatabaseException

Instantiate the object by executing the query on the session.

Annotations
@SuppressWarnings:unchecked
instantiateForUnitOfWorkValueHolderback to summary
public T instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder<T> unitOfWorkValueHolder)

Implements abstract org.eclipse.persistence.internal.indirection.DatabaseValueHolder.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.

Note

This method is not thread-safe. It must be used in a synchronized manner

Annotations
@Override
isPessimisticLockingValueHolderback to summary
public boolean isPessimisticLockingValueHolder()

Implements abstract org.eclipse.persistence.internal.indirection.DatabaseValueHolder.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 instantiated all fields can not be reset.

Since locks will be issued each time this valueholder is triggered, triggering this directly on the session in auto commit mode will generate an exception. This only UnitOfWorkValueHolder's wrapping this can trigger it.

Note

This method is not thread-safe. It must be used in a synchronized manner

Annotations
@Override
postInstantiateback to summary
public void postInstantiate()

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.postInstantiate.

INTERNAL: Run any extra code required after the valueholder instantiates For query based VH, we notify the cache that the valueholder has been triggered

Annotations
@Override
releaseWrappedValueHolderback to summary
public void releaseWrappedValueHolder(AbstractSession targetSession)

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.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.

Annotations
@Override
resetFieldsback to summary
protected void resetFields()

Overrides org.eclipse.persistence.internal.indirection.DatabaseValueHolder.resetFields.

Reset all the fields that are not needed after instantiation.

Annotations
@Override
setQueryback to summary
protected void setQuery(ReadQuery theQuery)

Set the query.

setRefreshCascadePolicyback to summary
public void setRefreshCascadePolicy(Integer refreshCascadePolicy)

INTERNAL:

setSourceObjectback to summary
public void setSourceObject(Object sourceObject)