Module org.eclipse.persistence.core
Class BatchValueHolder<T>
java.lang.Object
org.eclipse.persistence.internal.indirection.DatabaseValueHolder<T>
org.eclipse.persistence.internal.indirection.QueryBasedValueHolder<T>
org.eclipse.persistence.internal.indirection.BatchValueHolder<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,ValueHolderInterface<T>
,WeavedAttributeValueHolderInterface<T>
BatchValueHolder is used by the mappings that use indirection when using query optimization (batch reading).
This value holder is different from QueryBasedValueHolder in that its value must be extracted from one of the
results return by the query, not the entire result.
The query is also shared by all other value holders within the batch and it must be ensured that the query is only
executed once. Concurrency must also be maintained across all of the value holders in the batch.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ForeignReferenceMapping
protected ObjectLevelReadQuery
protected CacheKey
Fields inherited from class org.eclipse.persistence.internal.indirection.QueryBasedValueHolder
query, refreshCascade, sourceObject
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
ConstructorsConstructorDescriptionBatchValueHolder
(ReadQuery query, AbstractRecord row, ForeignReferenceMapping mapping, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) Initialize the query-based value holder. -
Method Summary
Modifier and TypeMethodDescriptionprotected ForeignReferenceMapping
protected T
instantiate
(AbstractSession session) Instantiate the object by having the mapping extract its value from the query.instantiateForUnitOfWorkValueHolder
(UnitOfWorkValueHolder<T> unitOfWorkValueHolder) Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).boolean
INTERNAL: Answers if this valueholder is easy to instantiate.protected void
Reset all the fields that are not needed after instantiation.protected void
setMapping
(ForeignReferenceMapping mapping) Methods inherited from class org.eclipse.persistence.internal.indirection.QueryBasedValueHolder
getQuery, getRefreshCascadePolicy, getValue, instantiate, isPessimisticLockingValueHolder, postInstantiate, releaseWrappedValueHolder, setQuery, setRefreshCascadePolicy, setSourceObject
Methods inherited from class org.eclipse.persistence.internal.indirection.DatabaseValueHolder
clone, getRow, getSession, getValue, getWrappedValueHolder, isCoordinatedWithProperty, isInstantiated, isNewlyWeavedValueHolder, isSerializedRemoteUnitOfWorkValueHolder, isTransactionalValueHolder, privilegedSetValue, setInstantiated, setIsCoordinatedWithProperty, setIsNewlyWeavedValueHolder, setRow, setSession, setUninstantiated, setValue, shouldAllowInstantiationDeferral, toString
-
Field Details
-
mapping
-
originalQuery
-
parentCacheKey
-
-
Constructor Details
-
BatchValueHolder
public BatchValueHolder(ReadQuery query, AbstractRecord row, ForeignReferenceMapping mapping, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey) Initialize the query-based value holder.- Parameters:
query
- The query that returns the object when executed.row
- The row representation of the object.mapping
- The mapping that is uses batch reading.
-
-
Method Details
-
getMapping
-
instantiate
Instantiate the object by having the mapping extract its value from the query. Concurrency must be maintained across all of the value holders, since they all share the same query, the extractResultFromBatchQuery method must be synchronized.- Overrides:
instantiate
in classQueryBasedValueHolder<T>
- Throws:
EclipseLinkException
-
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. The batch value holder must use a batch query relative to the unit of work, as the batch is local to the unit of work.
- Overrides:
instantiateForUnitOfWorkValueHolder
in classQueryBasedValueHolder<T>
-
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.
-
resetFields
protected void resetFields()Reset all the fields that are not needed after instantiation.- Overrides:
resetFields
in classQueryBasedValueHolder<T>
-
setMapping
-