Class 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
    • 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

      • 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 class QueryBasedValueHolder
      • isEasilyInstantiated

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