org.apache.cayenne.query

## Interface QueryRouter

-     public interface QueryRouter

  An interface used by Queries to route themselves to an appropriate QueryEngine. As of 1.2 QueryRouter only supports routing by DataMap.
  Since:
    1.2

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `QueryEngine` | `engineForDataMap(DataMap map)` Returns a QueryEngine that is configured to handle a given DataMap.
    `QueryEngine` | `engineForName(String name)` Returns a QueryEngine for a given name.
    `void` | `route(QueryEngine engine, Query query, Query substitutedQuery)` A callback method that allows a query to set its preferred engine during the routing phase.

- - ### Method Detail

    - #### route

          void route(QueryEngine engine,
                     Query query,
                     Query substitutedQuery)

      A callback method that allows a query to set its preferred engine during the routing phase. It allows query to further customize its routing, e.g. it is possible to implement query chains that pass multiple queries for execution.
      Parameters:
        `engine` - engine to use for query execution
        `query` - A query to execute.
        `substitutedQuery` - a query that was substituted for "query". Results must be mapped back to substituted query.

    - #### engineForName

          QueryEngine engineForName(String name)

      Returns a QueryEngine for a given name. If the name is null, a default QueryEngine is returned. If there's no default engine, an exception is thrown.
      Since:
        4.0

    - #### engineForDataMap

          QueryEngine engineForDataMap(DataMap map)

      Returns a QueryEngine that is configured to handle a given DataMap.
      Throws:
        `CayenneRuntimeException` - if an engine can't be found.
        `NullPointerException` - if a map parameter is null.

Copyright © 2001–2021 Apache Cayenne. All rights reserved.