Class BatchValueHolder
- java.lang.Object
-
- org.eclipse.persistence.internal.indirection.DatabaseValueHolder
-
- org.eclipse.persistence.internal.indirection.QueryBasedValueHolder
-
- org.eclipse.persistence.internal.indirection.BatchValueHolder
-
- All Implemented Interfaces:
Serializable
,Cloneable
,ValueHolderInterface
,WeavedAttributeValueHolderInterface
public class BatchValueHolder extends QueryBasedValueHolder
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:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ForeignReferenceMapping
mapping
protected ObjectLevelReadQuery
originalQuery
protected CacheKey
parentCacheKey
-
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
Constructors Constructor Description BatchValueHolder(ReadQuery query, AbstractRecord row, ForeignReferenceMapping mapping, ObjectLevelReadQuery originalQuery, CacheKey parentCacheKey)
Initialize the query-based value holder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ForeignReferenceMapping
getMapping()
protected Object
instantiate(AbstractSession session)
Instantiate the object by having the mapping extract its value from the query.Object
instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder unitOfWorkValueHolder)
Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).boolean
isEasilyInstantiated()
INTERNAL: Answers if this valueholder is easy to instantiate.protected void
resetFields()
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 Detail
-
mapping
protected transient ForeignReferenceMapping mapping
-
originalQuery
protected transient ObjectLevelReadQuery originalQuery
-
parentCacheKey
protected transient CacheKey parentCacheKey
-
-
Constructor Detail
-
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 Detail
-
getMapping
protected ForeignReferenceMapping getMapping()
-
instantiate
protected Object instantiate(AbstractSession session) throws EclipseLinkException
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
- Throws:
EclipseLinkException
-
instantiateForUnitOfWorkValueHolder
public 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. 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
-
isEasilyInstantiated
public boolean isEasilyInstantiated()
INTERNAL: Answers if this valueholder is easy to instantiate.- Overrides:
isEasilyInstantiated
in classDatabaseValueHolder
- 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
-
setMapping
protected void setMapping(ForeignReferenceMapping mapping)
-
-