/** * INTERNAL: * Extract the correct query result from the transporter. */ @Override public Object extractRemoteResult(Transporter transporter) { return ((DistributedSession)getSession()).getObjectsCorrespondingToAll(transporter.getObject(), transporter.getObjectDescriptors(), new IdentityHashMap(), this, getContainerPolicy()); }
/** * INTERNAL: * Extract the correct query result from the transporter. */ public Object extractRemoteResult(Transporter transporter) { return ((RemoteSession)getSession()).getObjectsCorrespondingToAll(transporter.getObject(), transporter.getObjectDescriptors(), new IdentityHashMap(), this, getContainerPolicy()); }
/** * INTERNAL: * Extract the correct query result from the transporter. */ @Override public Object extractRemoteResult(Transporter transporter) { return ((DistributedSession)getSession()).getObjectsCorrespondingToAll(transporter.getObject(), transporter.getObjectDescriptors(), new IdentityHashMap(), this, getContainerPolicy()); }
/** * INTERNAL: * Select all objects for a concrete descriptor. */ protected Object selectAllObjects(ReadAllQuery query) { ReadAllQuery concreteQuery = (ReadAllQuery)prepareQuery(query); return query.getSession().executeQuery(concreteQuery, query.getTranslationRow()); }
/** * INTERNAL: * Select all objects for a concrete descriptor. */ protected Object selectAllObjects(ReadAllQuery query) { ReadAllQuery concreteQuery = (ReadAllQuery)prepareQuery(query); return query.getSession().executeQuery(concreteQuery, query.getTranslationRow()); }
/** * INTERNAL: * Select all objects for an interface descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the objects. */ public Object selectAllObjectsUsingMultipleTableSubclassRead(ReadAllQuery query) throws DatabaseException { ContainerPolicy containerPolicy = query.getContainerPolicy(); Object objects = containerPolicy.containerInstance(); if (query.shouldIncludeData()) { ComplexQueryResult result = new ComplexQueryResult(); result.setResult(objects); result.setData(new ArrayList()); objects = result; } int size = this.childDescriptors.size(); for (int index = 0; index < size; index++) { ClassDescriptor descriptor = this.childDescriptors.get(index); objects = containerPolicy.concatenateContainers( objects, descriptor.getInterfacePolicy().selectAllObjects(query), query.getSession()); } return objects; }
/** * INTERNAL: * Select all objects for an interface descriptor. * This is accomplished by selecting for all of the concrete classes and then merging the objects. */ public Object selectAllObjectsUsingMultipleTableSubclassRead(ReadAllQuery query) throws DatabaseException { ContainerPolicy containerPolicy = query.getContainerPolicy(); Object objects = containerPolicy.containerInstance(); if (query.shouldIncludeData()) { ComplexQueryResult result = new ComplexQueryResult(); result.setResult(objects); result.setData(new ArrayList()); objects = result; } int size = this.childDescriptors.size(); for (int index = 0; index < size; index++) { ClassDescriptor descriptor = this.childDescriptors.get(index); objects = containerPolicy.concatenateContainers( objects, descriptor.getInterfacePolicy().selectAllObjects(query), query.getSession()); } return objects; }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override public void prepareForExecution() throws QueryException { super.prepareForExecution(); this.containerPolicy.prepareForExecution(); // Modifying the translation row here will modify it on the original // query which is not good. So we have to clone the translation row if // we are going to append tenant discriminator fields to it. if (descriptor.hasMultitenantPolicy()) { translationRow = translationRow.clone(); descriptor.getMultitenantPolicy().addFieldsToRow(translationRow, getSession()); } }
/** * INTERNAL: * <P> This method is called by the object builder when building an original. * It will cause the original to be cached in the query results if the query * is set to do so. */ public void cacheResult(Object unwrappedOriginal) { Collection container = (Collection)getTemporaryCachedQueryResults(); if (container == null) { container = (Collection)getContainerPolicy().containerInstance(); setTemporaryCachedQueryResults(container); } getContainerPolicy().addInto(unwrappedOriginal, container, getSession()); }
/** * INTERNAL: * <P> This method is called by the object builder when building an original. * It will cause the original to be cached in the query results if the query * is set to do so. */ @Override public void cacheResult(Object unwrappedOriginal) { Collection container = (Collection)getTemporaryCachedQueryResults(); if (container == null) { container = (Collection)getContainerPolicy().containerInstance(); setTemporaryCachedQueryResults(container); } getContainerPolicy().addInto(unwrappedOriginal, container, getSession()); }
/** * INTERNAL: * <P> This method is called by the object builder when building an original. * It will cause the original to be cached in the query results if the query * is set to do so. */ @Override public void cacheResult(Object unwrappedOriginal) { Collection container = (Collection)getTemporaryCachedQueryResults(); if (container == null) { container = (Collection)getContainerPolicy().containerInstance(); setTemporaryCachedQueryResults(container); } getContainerPolicy().addInto(unwrappedOriginal, container, getSession()); }
/** * INTERNAL: * Prepare the receiver for execution in a session. */ @Override public void prepareForExecution() throws QueryException { super.prepareForExecution(); this.containerPolicy.prepareForExecution(); // Modifying the translation row here will modify it on the original // query which is not good. So we have to clone the translation row if // we are going to append tenant discriminator fields to it. if (descriptor.hasMultitenantPolicy()) { translationRow = translationRow.clone(); descriptor.getMultitenantPolicy().addFieldsToRow(translationRow, getSession()); } }
/** * INTERNAL: * Add additional fields and check for history. */ protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ReadAllQuery query) { ReadAllQuery mappingBatchQuery = (ReadAllQuery)batchQuery; mappingBatchQuery.setShouldIncludeData(true); for (Enumeration relationFieldsEnum = getSourceRelationKeyFields().elements(); relationFieldsEnum.hasMoreElements();) { mappingBatchQuery.getAdditionalFields().add(mappingBatchQuery.getExpressionBuilder().getTable(getRelationTable()).getField((DatabaseField)relationFieldsEnum.nextElement())); } if (getHistoryPolicy() != null) { ExpressionBuilder builder = mappingBatchQuery.getExpressionBuilder(); Expression twisted = batchQuery.getSelectionCriteria(); if (query.getSession().getAsOfClause() != null) { builder.asOf(query.getSession().getAsOfClause()); } else if (builder.getAsOfClause() == null) { builder.asOf(AsOfClause.NO_CLAUSE); } twisted = twisted.and(getHistoryPolicy().additionalHistoryExpression(builder)); mappingBatchQuery.setSelectionCriteria(twisted); } }
/** * INTERNAL: * Execute the query through remote session. */ public Object remoteExecute() { if (getContainerPolicy().overridesRead()) { return getContainerPolicy().remoteExecute(); } Object cacheHit = checkEarlyReturn(getSession(), getTranslationRow()); if (cacheHit != null) { return cacheHit; } return super.remoteExecute(); }
builder.setSession(getSession().getRootSession(null)); builder.setQueryClass(getReferenceClass());
/** * INTERNAL: * Clone and prepare the selection query as a nested batch read query. * This is used for nested batch reading. */ public ReadQuery prepareNestedBatchQuery(ReadAllQuery query) { ReadAllQuery batchQuery = (ReadAllQuery)super.prepareNestedBatchQuery(query); if(this.listOrderField != null) { batchQuery.addAdditionalField(getListOrderFieldExpression(batchQuery.getExpressionBuilder())); } if (batchQuery.shouldPrepare()) { batchQuery.checkPrepare(query.getSession(), query.getTranslationRow()); } batchQuery.setSession(null); return batchQuery; }
/** * INTERNAL: * Select all objects for a concrete descriptor. */ protected Object selectAllObjects(ReadAllQuery query) { ReadAllQuery concreteQuery = (ReadAllQuery) query.deepClone(); concreteQuery.setReferenceClass(descriptor.getJavaClass()); concreteQuery.setDescriptor(descriptor); // Avoid cloning the query again ... concreteQuery.setIsExecutionClone(true); concreteQuery.getExpressionBuilder().setQueryClassAndDescriptor(descriptor.getJavaClass(), descriptor); // Update the selection criteria if needed as well and don't lose // the translation row. if (concreteQuery.getQueryMechanism().getSelectionCriteria() != null) { //make sure query builder is used for the selection criteria as deepClone will create //two separate builders. concreteQuery.setSelectionCriteria(concreteQuery.getQueryMechanism().getSelectionCriteria().rebuildOn(concreteQuery.getExpressionBuilder())); return query.getSession().executeQuery(concreteQuery, query.getTranslationRow()); } return query.getSession().executeQuery(concreteQuery); }
/** * 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(); }
this.containerPolicy.prepare(this, getSession());
this.containerPolicy.prepare(this, getSession());