Class QueryBasedValueHolder<T>
- All Implemented Interfaces:
Serializable
,Cloneable
,ValueHolderInterface<T>
,WeavedAttributeValueHolderInterface<T>
- Direct Known Subclasses:
BatchValueHolder
,EISOneToManyQueryBasedValueHolder
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected ReadQuery
Stores the query to be executed.protected Integer
protected Object
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
ModifierConstructorDescriptionprotected
QueryBasedValueHolder
(ReadQuery query, Object sourceObject, AbstractRecord row, AbstractSession session) Initialize the query-based value holder.QueryBasedValueHolder
(ReadQuery query, AbstractRecord row, AbstractSession session) Initialize the query-based value holder. -
Method Summary
Modifier and TypeMethodDescriptiongetQuery()
Return the query.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.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 T
Instantiate the object.protected T
instantiate
(AbstractSession session) Instantiate the object by executing the query on the session.instantiateForUnitOfWorkValueHolder
(UnitOfWorkValueHolder<T> unitOfWorkValueHolder) Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).boolean
INTERNAL: Answers if this valueholder is a pessimistic locking one.void
INTERNAL: Run any extra code required after the valueholder instantiates For query based VH, we notify the cache that the valueholder has been triggeredvoid
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.protected void
Set the query.void
setRefreshCascadePolicy
(Integer refreshCascadePolicy) INTERNAL:void
setSourceObject
(Object sourceObject) Methods inherited from class org.eclipse.persistence.internal.indirection.DatabaseValueHolder
clone, getRow, getSession, getValue, getWrappedValueHolder, isCoordinatedWithProperty, isEasilyInstantiated, isInstantiated, isNewlyWeavedValueHolder, isSerializedRemoteUnitOfWorkValueHolder, isTransactionalValueHolder, privilegedSetValue, setInstantiated, setIsCoordinatedWithProperty, setIsNewlyWeavedValueHolder, setRow, setSession, setUninstantiated, setValue, shouldAllowInstantiationDeferral, toString
-
Field Details
-
query
Stores the query to be executed. -
sourceObject
-
refreshCascade
-
-
Constructor Details
-
QueryBasedValueHolder
protected QueryBasedValueHolder() -
QueryBasedValueHolder
Initialize the query-based value holder. -
QueryBasedValueHolder
public QueryBasedValueHolder(ReadQuery query, Object sourceObject, AbstractRecord row, AbstractSession session) Initialize the query-based value holder.
-
-
Method Details
-
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. -
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.- Overrides:
getValue
in classDatabaseValueHolder<T>
-
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. -
instantiate
Description copied from class:DatabaseValueHolder
Instantiate the object.- Specified by:
instantiate
in classDatabaseValueHolder<T>
- Throws:
DatabaseException
-
instantiate
Instantiate the object by executing the query on the session.- Throws:
DatabaseException
-
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
- Specified by:
instantiateForUnitOfWorkValueHolder
in classDatabaseValueHolder<T>
-
postInstantiate
public void 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- Overrides:
postInstantiate
in classDatabaseValueHolder<T>
- See Also:
-
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.
- Overrides:
releaseWrappedValueHolder
in classDatabaseValueHolder<T>
-
resetFields
protected void resetFields()Reset all the fields that are not needed after instantiation.- Overrides:
resetFields
in classDatabaseValueHolder<T>
-
setQuery
Set the query. -
isPessimisticLockingValueHolder
public boolean 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
- Specified by:
isPessimisticLockingValueHolder
in classDatabaseValueHolder<T>
-
setSourceObject
-
setRefreshCascadePolicy
INTERNAL:
-