org.apache.cayenne.query

## Class QueryChain

- java.lang.Object
- - org.apache.cayenne.query.QueryChain

- All Implemented Interfaces:
    Serializable, ConfigurationNode, Query

      public class QueryChain
      extends Object
      implements Query

  A Query decorator for a collection of other queries. Note that QueryChain will always return DataRows (that is if it returns data), as it has no way of knowing how to convert the results to objects.
  Since:
    1.2
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Collection<Query>` | `chain`
    `protected DataMap` | `dataMap`
    `protected String` | `name`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `QueryChain()` Creates an empty QueryChain.
    `QueryChain(Collection<? extends Query> queries)` Creates a new QueryChain with a collection of Queries.
    `QueryChain(Query[] queries)` Creates a new QueryChain out of an array of queries.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `<T> T` | `acceptVisitor(ConfigurationNodeVisitor<T> visitor)`
    `void` | `addQuery(Query query)` Adds a query to the chain.
    `SQLAction` | `createSQLAction(SQLActionVisitor visitor)` Throws an exception as execution should've been delegated to the queries contained in the chain.
    `DataMap` | `getDataMap()`
    `QueryMetadata` | `getMetaData(EntityResolver resolver)` Returns default metadata.
    `String` | `getName()` Returns a symbolic name of the query.
    `boolean` | `isEmpty()`
    `boolean` | `removeQuery(Query query)` Removes a query from the chain, returning true if the query was indeed present in the chain and was removed.
    `void` | `route(QueryRouter router, EntityResolver resolver, Query substitutedQuery)` Delegates routing to each individual query in the chain.
    `void` | `setDataMap(DataMap dataMap)`
    `void` | `setName(String name)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### chain

          protected Collection<Query> chain

    - #### name

          protected String name

    - #### dataMap

          protected DataMap dataMap

      Since:
        3.1

  - ### Constructor Detail

    - #### QueryChain

          public QueryChain()

      Creates an empty QueryChain.

    - #### QueryChain

          public QueryChain(Query[] queries)

      Creates a new QueryChain out of an array of queries.

    - #### QueryChain

          public QueryChain(Collection<? extends Query> queries)

      Creates a new QueryChain with a collection of Queries.

  - ### Method Detail

    - #### acceptVisitor

          public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)

      Specified by:
        `acceptVisitor` in interface `ConfigurationNode`
      Since:
        3.1

    - #### addQuery

          public void addQuery(Query query)

      Adds a query to the chain.

    - #### removeQuery

          public boolean removeQuery(Query query)

      Removes a query from the chain, returning true if the query was indeed present in the chain and was removed.

    - #### isEmpty

          public boolean isEmpty()

    - #### route

          public void route(QueryRouter router,
                            EntityResolver resolver,
                            Query substitutedQuery)

      Delegates routing to each individual query in the chain. If there is no queries, this method does nothing.
      Specified by:
        `route` in interface `Query`

    - #### createSQLAction

          public SQLAction createSQLAction(SQLActionVisitor visitor)

      Throws an exception as execution should've been delegated to the queries contained in the chain.
      Specified by:
        `createSQLAction` in interface `Query`

    - #### getName

          public String getName()

      Description copied from interface: `Query`
      Returns a symbolic name of the query. The name is normally used as a key to find queries stored in the DataMap.
      Specified by:
        `getName` in interface `Query`

    - #### setName

          public void setName(String name)

    - #### getDataMap

          public DataMap getDataMap()

      Specified by:
        `getDataMap` in interface `Query`
      Since:
        3.1

    - #### setDataMap

          public void setDataMap(DataMap dataMap)

      Since:
        3.1

    - #### getMetaData

          public QueryMetadata getMetaData(EntityResolver resolver)

      Returns default metadata.
      Specified by:
        `getMetaData` in interface `Query`

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