All Implemented Interfaces:
Serializable, Cloneable, ValueHolderInterface<T>, WeavedAttributeValueHolderInterface<T>

public class BatchValueHolder<T> extends QueryBasedValueHolder<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 Details

  • 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

      protected ForeignReferenceMapping getMapping()
    • instantiate

      protected T 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 class QueryBasedValueHolder<T>
      Throws:
      EclipseLinkException
    • instantiateForUnitOfWorkValueHolder

      public T instantiateForUnitOfWorkValueHolder(UnitOfWorkValueHolder<T> 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 class QueryBasedValueHolder<T>
    • isEasilyInstantiated

      public boolean isEasilyInstantiated()
      INTERNAL: Answers if this valueholder is easy to instantiate.
      Overrides:
      isEasilyInstantiated in class DatabaseValueHolder<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 class QueryBasedValueHolder<T>
    • setMapping

      protected void setMapping(ForeignReferenceMapping mapping)