/**
  * INTERNAL: Return the value to be stored in the object's attribute. This value is determined by
  * the batchQuery. In this case, extract the result from the query.
  */
 public Object valueFromBatchQuery(
     ReadQuery batchQuery,
     AbstractRecord row,
     ObjectLevelReadQuery originalQuery,
     CacheKey parentCacheKey) {
   return getForeignReferenceMapping()
       .extractResultFromBatchQuery(
           batchQuery, parentCacheKey, row, originalQuery.getSession(), originalQuery);
 }
 /**
  * Initialize the query-based value holder.
  *
  * @param query The query that returns the object when executed.
  * @param row The row representation of the object.
  * @param mapping The mapping that is uses batch reading.
  */
 public BatchValueHolder(
     ReadQuery query,
     AbstractRecord row,
     ForeignReferenceMapping mapping,
     ObjectLevelReadQuery originalQuery,
     CacheKey parentCacheKey) {
   super(query, row, originalQuery.getSession());
   this.mapping = mapping;
   this.originalQuery = originalQuery;
   this.parentCacheKey = parentCacheKey;
 }
 /**
  * INTERNAL: Prepare the query from the prepared query. This allows a dynamic query to prepare
  * itself directly from a prepared query instance. This is used in the JPQL parse cache to allow
  * preparsed queries to be used to prepare dynamic queries. This only copies over properties that
  * are configured through JPQL.
  */
 public void prepareFromQuery(DatabaseQuery query) {
   super.prepareFromQuery(query);
   if (query.isReadAllQuery()) {
     ReadAllQuery readQuery = (ReadAllQuery) query;
     this.containerPolicy = readQuery.containerPolicy;
     if (readQuery.hasHierarchicalExpressions()) {
       this.orderSiblingsByExpressions = readQuery.getOrderSiblingsByExpressions();
       this.connectByExpression = readQuery.getConnectByExpression();
       this.startWithExpression = readQuery.getStartWithExpression();
     }
     if (readQuery.hasBatchReadAttributes()) {
       this.batchReadAttributeExpressions = readQuery.batchReadAttributeExpressions;
       this.batchReadMappingQueries = readQuery.batchReadMappingQueries;
       this.batchReadAttributes = readQuery.batchReadAttributes;
     }
   }
 }
  /** INTERNAL: Prepare the receiver for execution in a session. */
  protected void prepare() throws QueryException {
    if ((!isReportQuery()) && prepareFromCachedQuery()) {
      return;
    }
    super.prepare();

    getContainerPolicy().prepare(this, getSession());

    if (getContainerPolicy().overridesRead()) {
      return;
    }

    if (getDescriptor().isDescriptorForInterface()) {
      return;
    }

    prepareSelectAllRows();
    computeBatchReadMappingQueries();
  }
  /** INTERNAL: Prepare the receiver for execution in a session. */
  public void prepareForExecution() throws QueryException {
    super.prepareForExecution();

    getContainerPolicy().prepareForExecution();
  }