/** * INTERNAL: * Return temporary map of batched objects. */ public Map<Object, Object> getBatchObjects() { return getBatchFetchPolicy().getBatchObjects(); }
/** * INTERNAL: * Set all attributes specified for batch reading. */ public void setBatchReadAttributeExpressions(List<Expression> attributeExpressions) { if ((this.batchFetchPolicy == null) && (attributeExpressions.isEmpty())) { return; } getBatchFetchPolicy().setAttributeExpressions(attributeExpressions); }
/** * INTERNAL: * Return all attributes specified for batch reading. */ public List<Expression> getBatchReadAttributeExpressions() { return getBatchFetchPolicy().getAttributeExpressions(); }
/** * INTERNAL: * Set all attributes specified for batch reading. */ public void setBatchReadAttributeExpressions(List<Expression> attributeExpressions) { if ((this.batchFetchPolicy == null) && (attributeExpressions.isEmpty())) { return; } getBatchFetchPolicy().setAttributeExpressions(attributeExpressions); }
/** * INTERNAL: * Return temporary map of batched objects. */ public Map<Object, Object> getBatchObjects() { return getBatchFetchPolicy().getBatchObjects(); }
/** * INTERNAL: * Set temporary map of batched objects. */ public void setBatchObjects(Map<Object, Object> batchObjects) { getBatchFetchPolicy().setBatchObjects(batchObjects); }
/** * INTERNAL: * Set temporary map of batched objects. */ public void setBatchObjects(Map<Object, Object> batchObjects) { getBatchFetchPolicy().setBatchObjects(batchObjects); }
/** * INTERNAL: * Return all attributes specified for batch reading. */ public List<Expression> getBatchReadAttributeExpressions() { return getBatchFetchPolicy().getAttributeExpressions(); }
/** * PUBLIC: * Set the batch fetch size for the query. * This is only relevant for the IN batch fetch type. * This defines the max number of keys for the IN clause. * * @see #setBatchFetchType(BatchFetchType) * @see #addBatchReadAttribute(Expression) */ public void setBatchFetchSize(int size) { getBatchFetchPolicy().setSize(size); setIsPrepared(false); }
/** * PUBLIC: * Set the batch fetch type for the query. * This can be JOIN, EXISTS, or IN. * This defines the type of batch reading to use with the query. * The query must have defined batch read attributes to set its fetch type. * * @see #addBatchReadAttribute(Expression) */ public void setBatchFetchType(BatchFetchType type) { getBatchFetchPolicy().setType(type); setIsPrepared(false); }
/** * PUBLIC: * Set the batch fetch size for the query. * This is only relevant for the IN batch fetch type. * This defines the max number of keys for the IN clause. * * @see #setBatchFetchType(BatchFetchType) * @see #addBatchReadAttribute(Expression) */ public void setBatchFetchSize(int size) { getBatchFetchPolicy().setSize(size); setIsPrepared(false); }
/** * PUBLIC: * Set the batch fetch type for the query. * This can be JOIN, EXISTS, or IN. * This defines the type of batch reading to use with the query. * The query must have defined batch read attributes to set its fetch type. * * @see #addBatchReadAttribute(Expression) */ public void setBatchFetchType(BatchFetchType type) { getBatchFetchPolicy().setType(type); setIsPrepared(false); }
/** * INTERNAL: * Retrieve the value through using batch reading. * This executes a single query to read the target for all of the objects and stores the * result of the batch query in the original query to allow the other objects to share the results. */ protected Object batchedValueFromRow(AbstractRecord row, ObjectLevelReadQuery query, CacheKey parentCacheKey) { ReadQuery batchQuery = (ReadQuery)query.getProperty(this); if (batchQuery == null) { if (query.hasBatchReadAttributes()) { Map<DatabaseMapping, ReadQuery> queries = query.getBatchFetchPolicy().getMappingQueries(); if (queries != null) { batchQuery = queries.get(this); } } if (batchQuery == null) { batchQuery = prepareNestedBatchQuery(query); batchQuery.setIsExecutionClone(true); } else { batchQuery = (ReadQuery)batchQuery.clone(); batchQuery.setIsExecutionClone(true); } query.setProperty(this, batchQuery); } return this.indirectionPolicy.valueFromBatchQuery(batchQuery, row, query, parentCacheKey); }
/** * INTERNAL: * Retrieve the value through using batch reading. * This executes a single query to read the target for all of the objects and stores the * result of the batch query in the original query to allow the other objects to share the results. */ protected Object batchedValueFromRow(AbstractRecord row, ObjectLevelReadQuery query, CacheKey parentCacheKey) { ReadQuery batchQuery = (ReadQuery)query.getProperty(this); if (batchQuery == null) { if (query.hasBatchReadAttributes()) { Map<DatabaseMapping, ReadQuery> queries = query.getBatchFetchPolicy().getMappingQueries(); if (queries != null) { batchQuery = queries.get(this); } } if (batchQuery == null) { batchQuery = prepareNestedBatchQuery(query); batchQuery.setIsExecutionClone(true); } else { batchQuery = (ReadQuery)batchQuery.clone(); batchQuery.setIsExecutionClone(true); } query.setProperty(this, batchQuery); } return this.indirectionPolicy.valueFromBatchQuery(batchQuery, row, query, parentCacheKey); }
/** * INTERNAL: * builds and registers an object from a row for cursors. * Behavior is different from the query version in that refreshing is not * supported. */ protected Object buildAndRegisterObject(AbstractRecord row) { ReadQuery query = this.query; if (query.isObjectLevelReadQuery()) { ObjectLevelReadQuery objectQuery = (ObjectLevelReadQuery)query; if (objectQuery.hasBatchReadAttributes() && objectQuery.getBatchFetchPolicy().isIN()) { objectQuery.getBatchFetchPolicy().addDataResults(row); } if (this.session.isUnitOfWork() && (!query.isReportQuery()) && query.shouldMaintainCache() && (objectQuery.shouldConformResultsInUnitOfWork() || objectQuery.getDescriptor().shouldAlwaysConformResultsInUnitOfWork())) { Object object = objectQuery.conformIndividualResult( objectQuery.buildObject(row), (UnitOfWorkImpl)this.session, this.translationRow, this.selectionCriteriaClone, this.initiallyConformingIndex); // Notifies caller to continue until conforming instance found if (object == null) { return InvalidObject.instance; } return object; } } return query.buildObject(row); }
/** * INTERNAL: * builds and registers an object from a row for cursors. * Behavior is different from the query version in that refreshing is not * supported. */ protected Object buildAndRegisterObject(AbstractRecord row) { ReadQuery query = this.query; if (query.isObjectLevelReadQuery()) { ObjectLevelReadQuery objectQuery = (ObjectLevelReadQuery)query; if (objectQuery.hasBatchReadAttributes() && objectQuery.getBatchFetchPolicy().isIN()) { objectQuery.getBatchFetchPolicy().addDataResults(row); } if (this.session.isUnitOfWork() && (!query.isReportQuery()) && query.shouldMaintainCache() && (objectQuery.shouldConformResultsInUnitOfWork() || objectQuery.getDescriptor().shouldAlwaysConformResultsInUnitOfWork())) { Object object = objectQuery.conformIndividualResult( objectQuery.buildObject(row), (UnitOfWorkImpl)this.session, this.translationRow, this.selectionCriteriaClone, this.initiallyConformingIndex); // Notifies caller to continue until conforming instance found if (object == null) { return InvalidObject.instance; } return object; } } return query.buildObject(row); }
/** * INTERNAL: * Allow the mapping the do any further batch preparation. */ @Override protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) { super.postPrepareNestedBatchQuery(batchQuery, query); // Force a distinct to filter out m-1 duplicates. // Only set if really a m-1, not a 1-1 if (!this.isOneToOneRelationship && ((ObjectLevelReadQuery)batchQuery).getBatchFetchPolicy().isJOIN()) { if (!((ObjectLevelReadQuery)batchQuery).isDistinctComputed() && (batchQuery.getSession().getPlatform().isLobCompatibleWithDistinct() || !Helper.hasLob(batchQuery.getDescriptor().getSelectionFields((ObjectLevelReadQuery)batchQuery)))) { ((ObjectLevelReadQuery)batchQuery).useDistinct(); } } if (this.mechanism != null) { this.mechanism.postPrepareNestedBatchQuery(batchQuery, query); } }
/** * INTERNAL: * Allow the mapping the do any further batch preparation. */ @Override protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) { super.postPrepareNestedBatchQuery(batchQuery, query); // Force a distinct to filter out m-1 duplicates. // Only set if really a m-1, not a 1-1 if (!this.isOneToOneRelationship && ((ObjectLevelReadQuery)batchQuery).getBatchFetchPolicy().isJOIN()) { if (!((ObjectLevelReadQuery)batchQuery).isDistinctComputed() && (batchQuery.getSession().getPlatform().isLobCompatibleWithDistinct() || !Helper.hasLob(batchQuery.getDescriptor().getSelectionFields((ObjectLevelReadQuery)batchQuery)))) { ((ObjectLevelReadQuery)batchQuery).useDistinct(); } } if (this.mechanism != null) { this.mechanism.postPrepareNestedBatchQuery(batchQuery, query); } }
this.batchFetchPolicy = objectQuery.getBatchFetchPolicy().clone();
this.batchFetchPolicy = objectQuery.getBatchFetchPolicy().clone();