Class CacheBasedValueHolder
- java.lang.Object
-
- org.eclipse.persistence.internal.indirection.DatabaseValueHolder
-
- org.eclipse.persistence.internal.indirection.CacheBasedValueHolder
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,ValueHolderInterface,WeavedAttributeValueHolderInterface
public class CacheBasedValueHolder extends DatabaseValueHolder
Purpose: In certain cases the contents of a relationship may be retrievable from a cache. This ValueHolder instance provides the mechanism to store a cached relationship and to load that relationship from a cache. This functionality requires that the persistent identities of the targets can be collected as database type foreign key queries are unavailable.
- Since:
- EclipseLink 1.1
- Author:
- gyorke
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ForeignReferenceMappingmappingprotected java.lang.Object[]referencesprotected booleanshouldAllowInstantiationDeferralSetting to force the instantiation of the Collection on modification-
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 CacheBasedValueHolder(java.lang.Object[] pks, AbstractRecord foreignKeys, AbstractSession session, ForeignReferenceMapping mapping)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object[]getCachedPKs()java.lang.ObjectgetValue(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 java.lang.Objectinstantiate()Instantiate the object.protected java.lang.Objectinstantiate(AbstractSession localSession)java.lang.ObjectinstantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder unitOfWorkValueHolder)Triggers UnitOfWork valueholders directly without triggering the wrapped valueholder (this).booleanisPessimisticLockingValueHolder()Answers if this valueholder is a pessimistic locking one.voidsetShouldAllowInstantiationDeferral(boolean shouldAllowInstantiationDeferral)Set if instantiation deferral on modification should be available.booleanshouldAllowInstantiationDeferral()INTERNAL: Return if add/remove should trigger instantiation or avoid.-
Methods inherited from class org.eclipse.persistence.internal.indirection.DatabaseValueHolder
clone, getRow, getSession, getValue, getWrappedValueHolder, isCoordinatedWithProperty, isEasilyInstantiated, isInstantiated, isNewlyWeavedValueHolder, isSerializedRemoteUnitOfWorkValueHolder, isTransactionalValueHolder, postInstantiate, privilegedSetValue, releaseWrappedValueHolder, resetFields, setInstantiated, setIsCoordinatedWithProperty, setIsNewlyWeavedValueHolder, setRow, setSession, setUninstantiated, setValue, toString
-
-
-
-
Field Detail
-
mapping
protected transient ForeignReferenceMapping mapping
-
references
protected java.lang.Object[] references
-
shouldAllowInstantiationDeferral
protected boolean shouldAllowInstantiationDeferral
Setting to force the instantiation of the Collection on modification
-
-
Constructor Detail
-
CacheBasedValueHolder
public CacheBasedValueHolder(java.lang.Object[] pks, AbstractRecord foreignKeys, AbstractSession session, ForeignReferenceMapping mapping)
-
-
Method Detail
-
getCachedPKs
public java.lang.Object[] getCachedPKs()
-
getValue
public java.lang.Object 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.- Overrides:
getValuein classDatabaseValueHolder
-
instantiate
protected java.lang.Object instantiate() throws DatabaseExceptionDescription copied from class:DatabaseValueHolderInstantiate the object.- Specified by:
instantiatein classDatabaseValueHolder- Throws:
DatabaseException
-
instantiate
protected java.lang.Object instantiate(AbstractSession localSession) throws DatabaseException
- Throws:
DatabaseException
-
instantiateForUnitOfWorkValueHolder
public java.lang.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
- Specified by:
instantiateForUnitOfWorkValueHolderin classDatabaseValueHolder
-
isPessimisticLockingValueHolder
public boolean isPessimisticLockingValueHolder()
Description copied from class:DatabaseValueHolderAnswers 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- Specified by:
isPessimisticLockingValueHolderin classDatabaseValueHolder
-
setShouldAllowInstantiationDeferral
public void setShouldAllowInstantiationDeferral(boolean shouldAllowInstantiationDeferral)
Set if instantiation deferral on modification should be available.
-
shouldAllowInstantiationDeferral
public boolean shouldAllowInstantiationDeferral()
INTERNAL: Return if add/remove should trigger instantiation or avoid. Current instantiation is avoided is using change tracking.- Specified by:
shouldAllowInstantiationDeferralin interfaceWeavedAttributeValueHolderInterface- Overrides:
shouldAllowInstantiationDeferralin classDatabaseValueHolder
-
-