org.eclipse.persistence.queries.QueryRedirector Maven / Gradle / Ivy
Show all versions of org.eclipse.persistence.core Show documentation
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.queries;
import java.io.Serializable;
import org.eclipse.persistence.sessions.*;
/**
* Purpose:
* Query redirection allows for a named or parameterized query (or finder) to dynamically determine how the query is to be executed based on the arguments.
*
*
Description:
* An implementor of this interface can be given to a query to allow the user to
* have full control over the execution of the query.
* Redirection can be used to:
*
* - Dynamically configure the query options based on the arguments (i.e. ordering, query optimization... etc.).
*
- Dynamically define the selection criteria based on the arguments.
*
- Pass Query By Example objects or Expressions as the arguments.
*
- Post process the query results.
*
- Perform multiple queries or non-EclipseLink operations.
*
*
* Note: If you execute the query on a UnitOfWork, the results register with that
* UnitOfWork, so any objects you attempt to retrieve with the invoke
* method must come from the Session Cache.
* @see MethodBaseQueryRedirector
* @see DatabaseQuery#setRedirector
* @author James Sutherland
* @since TOPLink/Java 3.0
*/
public interface QueryRedirector extends Serializable {
/**
* REQUIRED:
* Perform the query.
* This must execute the query base on the arguments and return a valid result for the query.
*/
Object invokeQuery(DatabaseQuery query, org.eclipse.persistence.sessions.Record arguments, Session session);
}