/** * ADVANCED: Sets the query to execute as of the past time. * Both the query execution and result will conform to the database as it * existed in the past. * <p> * Equivalent to query.getSelectionCriteria().asOf(pastTime) called * immediately before query execution. * <p>An as of clause at the query level will override any clauses set at the * expression level. Useful in cases where the selection criteria is not known in * advance, such as for query by example or primary key (selection object), or * where you do not need to cache the result (report query). * <p>Ideally an as of clause at the session level is superior as query * results can then be cached. You must set * {@link org.eclipse.persistence.queries.ObjectLevelReadQuery#setShouldMaintainCache setShouldMaintainCache(false)} * <p>To query all joined/batched attributes as of the same time set * this.{@link org.eclipse.persistence.queries.ObjectLevelReadQuery#cascadeAllParts cascadeAllParts()}. * @throws QueryException (at execution time) unless * <code>setShouldMaintainCache(false)</code> is set. If some more recent * data were in the cache, this would be returned instead, and both the * cache and query result would become inconsistent. * @since OracleAS TopLink 10<i>g</i> (10.0.3) * @see #hasAsOfClause * @see org.eclipse.persistence.sessions.Session#acquireHistoricalSession(org.eclipse.persistence.history.AsOfClause) * @see org.eclipse.persistence.expressions.Expression#asOf(org.eclipse.persistence.history.AsOfClause) */ public void setAsOfClause(AsOfClause pastTime) { getExpressionBuilder().asOf(new UniversalAsOfClause(pastTime)); setIsPrepared(false); }
/** * ADVANCED: Sets the query to execute as of the past time. * Both the query execution and result will conform to the database as it * existed in the past. * <p> * Equivalent to query.getSelectionCriteria().asOf(pastTime) called * immediately before query execution. * <p>An as of clause at the query level will override any clauses set at the * expression level. Useful in cases where the selection criteria is not known in * advance, such as for query by example or primary key (selection object), or * where you do not need to cache the result (report query). * <p>Ideally an as of clause at the session level is superior as query * results can then be cached. You must set * {@link org.eclipse.persistence.queries.ObjectLevelReadQuery#setShouldMaintainCache setShouldMaintainCache(false)} * <p>To query all joined/batched attributes as of the same time set * this.{@link org.eclipse.persistence.queries.ObjectLevelReadQuery#cascadeAllParts cascadeAllParts()}. * @throws QueryException (at execution time) unless * <code>setShouldMaintainCache(false)</code> is set. If some more recent * data were in the cache, this would be returned instead, and both the * cache and query result would become inconsistent. * @since OracleAS TopLink 10<i>g</i> (10.0.3) * @see #hasAsOfClause * @see org.eclipse.persistence.sessions.Session#acquireHistoricalSession(org.eclipse.persistence.history.AsOfClause) * @see org.eclipse.persistence.expressions.Expression#asOf(org.eclipse.persistence.history.AsOfClause) */ public void setAsOfClause(AsOfClause pastTime) { getExpressionBuilder().asOf(new UniversalAsOfClause(pastTime)); setIsPrepared(false); }
/** * ADVANCED: Sets the query to execute as of the past time. * Both the query execution and result will conform to the database as it * existed in the past. * <p> * Equivalent to query.getSelectionCriteria().asOf(pastTime) called * immediately before query execution. * <p>An as of clause at the query level will override any clauses set at the * expression level. Useful in cases where the selection criteria is not known in * advance, such as for query by example or primary key (selection object), or * where you do not need to cache the result (report query). * <p>Ideally an as of clause at the session level is superior as query * results can then be cached. You must set * {@link org.eclipse.persistence.queries.ObjectLevelReadQuery#setShouldMaintainCache setShouldMaintainCache(false)} * <p>To query all joined/batched attributes as of the same time set * this.{@link org.eclipse.persistence.queries.ObjectLevelReadQuery#cascadeAllParts cascadeAllParts()}. * @throws QueryException (at execution time) unless * <code>setShouldMaintainCache(false)</code> is set. If some more recent * data were in the cache, this would be returned instead, and both the * cache and query result would become inconsistent. * @since OracleAS TopLink 10<i>g</i> (10.0.3) * @see #hasAsOfClause * @see org.eclipse.persistence.sessions.Session#acquireHistoricalSession(org.eclipse.persistence.history.AsOfClause) * @see org.eclipse.persistence.expressions.Expression#asOf(org.eclipse.persistence.history.AsOfClause) */ public void setAsOfClause(AsOfClause pastTime) { getExpressionBuilder().asOf(new UniversalAsOfClause(pastTime)); setIsPrepared(false); }
public void setSelectionCriteria(Expression expression) { super.setSelectionCriteria(expression); if ((expression != null) && (defaultBuilder != null) && (defaultBuilder.getQueryClass() == null)){ // For flashback: Must make sure expression and defaultBuilder always in sync. ExpressionBuilder newBuilder = expression.getBuilder(); if (newBuilder != defaultBuilder) { if (hasAsOfClause() && getAsOfClause().isUniversal()) { newBuilder.asOf(defaultBuilder.getAsOfClause()); } defaultBuilder = newBuilder; } } }
/** * 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: * Add additional fields and check for history. */ @Override protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) { super.postPrepareNestedBatchQuery(batchQuery, query); ReadAllQuery mappingBatchQuery = (ReadAllQuery)batchQuery; this.mechanism.postPrepareNestedBatchQuery(batchQuery, query); if (this.historyPolicy != 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(this.historyPolicy.additionalHistoryExpression(builder, builder)); mappingBatchQuery.setSelectionCriteria(twisted); } }
/** * INTERNAL: * Add additional fields and check for history. */ @Override protected void postPrepareNestedBatchQuery(ReadQuery batchQuery, ObjectLevelReadQuery query) { super.postPrepareNestedBatchQuery(batchQuery, query); ReadAllQuery mappingBatchQuery = (ReadAllQuery)batchQuery; this.mechanism.postPrepareNestedBatchQuery(batchQuery, query); if (this.historyPolicy != 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(this.historyPolicy.additionalHistoryExpression(builder, builder)); mappingBatchQuery.setSelectionCriteria(twisted); } }
/** * PUBLIC: * Set the Expression/where clause of the query. * The expression should be defined using the query's ExpressionBuilder. */ @Override public void setSelectionCriteria(Expression expression) { super.setSelectionCriteria(expression); if ((expression != null) && (this.defaultBuilder != null) && (this.defaultBuilder.getQueryClass() == null)){ // For flashback: Must make sure expression and defaultBuilder always in sync. ExpressionBuilder newBuilder = expression.getBuilder(); if (newBuilder != this.defaultBuilder) { if (hasAsOfClause() && getAsOfClause().isUniversal()) { newBuilder.asOf(this.defaultBuilder.getAsOfClause()); } this.defaultBuilder = newBuilder; } } }
/** * PUBLIC: * Set the Expression/where clause of the query. * The expression should be defined using the query's ExpressionBuilder. */ @Override public void setSelectionCriteria(Expression expression) { super.setSelectionCriteria(expression); if ((expression != null) && (this.defaultBuilder != null) && (this.defaultBuilder.getQueryClass() == null)){ // For flashback: Must make sure expression and defaultBuilder always in sync. ExpressionBuilder newBuilder = expression.getBuilder(); if (newBuilder != this.defaultBuilder) { if (hasAsOfClause() && getAsOfClause().isUniversal()) { newBuilder.asOf(this.defaultBuilder.getAsOfClause()); } this.defaultBuilder = newBuilder; } } }
statement.getBuilder().asOf(((ObjectLevelReadQuery)sourceQuery).getAsOfClause()); ExpressionBuilder builder = statement.getBuilder(); if (sourceQuery.getSession().getAsOfClause() != null) { builder.asOf(sourceQuery.getSession().getAsOfClause()); } else if (builder.getAsOfClause() == null) { builder.asOf(AsOfClause.NO_CLAUSE);
asOf(AsOfClause.NO_CLAUSE);
statement.getBuilder().asOf(((ObjectLevelReadQuery)sourceQuery).getAsOfClause()); ExpressionBuilder builder = statement.getBuilder(); if (sourceQuery.getSession().getAsOfClause() != null) { builder.asOf(sourceQuery.getSession().getAsOfClause()); } else if (builder.getAsOfClause() == null) { builder.asOf(AsOfClause.NO_CLAUSE);
statement.getBuilder().asOf(((ObjectLevelReadQuery)sourceQuery).getAsOfClause()); ExpressionBuilder builder = statement.getBuilder(); if (sourceQuery.getSession().getAsOfClause() != null) { builder.asOf(sourceQuery.getSession().getAsOfClause()); } else if (builder.getAsOfClause() == null) { builder.asOf(AsOfClause.NO_CLAUSE);
asOf(AsOfClause.NO_CLAUSE);
asOf(AsOfClause.NO_CLAUSE);