# Class QueryDescriptor

java.lang.Object
org.apache.cayenne.map.QueryDescriptor

All Implemented Interfaces:
  `Serializable, ConfigurationNode, XMLSerializable`

Direct Known Subclasses:
  `EJBQLQueryDescriptor, ProcedureQueryDescriptor, SelectQueryDescriptor, SQLTemplateDescriptor`

public class QueryDescriptor extends Object implements Serializable, ConfigurationNode, XMLSerializable
Generic descriptor of a Cayenne query.

Since:
  4.0
See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `DATA_MAP_ROOT`
  `protected DataMap`
  `dataMap`
  `static final String`
  `DB_ENTITY_ROOT`
  `static final String`
  `EJBQL_QUERY`
  `static final String`
  `JAVA_CLASS_ROOT`
  `protected String`
  `name`
  `static final String`
  `OBJ_ENTITY_ROOT`
  `static final String`
  `PROCEDURE_QUERY`
  `static final String`
  `PROCEDURE_ROOT`
  `protected Map<String,String>`
  `properties`
  `protected Object`
  `root`
  `static final String`
  `SELECT_QUERY`
  `static final String`
  `SQL_TEMPLATE`
  `protected String`
  `type`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `QueryDescriptor(String type)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> T`
  `acceptVisitor(ConfigurationNodeVisitor<T> visitor)`
  `Query`
  `buildQuery()`
  Assembles Cayenne query instance of appropriate type from this descriptor.
  `static QueryDescriptor`
  `descriptor(String type)`
  Creates query descriptor of a given type.
  `static EJBQLQueryDescriptor`
  `ejbqlQueryDescriptor()`
  Creates new EJBQLQuery query descriptor.
  `void`
  `encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)`
  Prints itself as XML to the provided XMLEncoder.
  `DataMap`
  `getDataMap()`
  `String`
  `getName()`
  Returns name of the query.
  `Map<String,String>`
  `getProperties()`
  Returns map of query properties set up for this query.
  `String`
  `getProperty(String name)`
  Returns query property by its name.
  `Object`
  `getRoot()`
  Returns the root of this query.
  `String`
  `getType()`
  Returns type of the query.
  `static ProcedureQueryDescriptor`
  `procedureQueryDescriptor()`
  Creates new ProcedureQuery query descriptor.
  `static SelectQueryDescriptor`
  `selectQueryDescriptor()`
  Creates new SelectQuery query descriptor.
  `void`
  `setDataMap(DataMap dataMap)`
  `void`
  `setName(String name)`
  Sets name of the query.
  `void`
  `setProperties(Map<String,String> properties)`
  Sets map of query properties for this query.
  `void`
  `setProperty(String name, String value)`
  Sets single query property.
  `void`
  `setRoot(Object root)`
  Sets the root of this query.
  `void`
  `setType(String type)`
  Sets type of the query.
  `static SQLTemplateDescriptor`
  `sqlTemplateDescriptor()`
  Creates new SQLTemplate query descriptor.

  ### Methods inherited from class Object

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

- ## Field Details

  - ### SELECT_QUERY

    public static final String SELECT_QUERY
    See Also:
      - Constant Field Values

  - ### SQL_TEMPLATE

    public static final String SQL_TEMPLATE
    See Also:
      - Constant Field Values

  - ### EJBQL_QUERY

    public static final String EJBQL_QUERY
    See Also:
      - Constant Field Values

  - ### PROCEDURE_QUERY

    public static final String PROCEDURE_QUERY
    See Also:
      - Constant Field Values

  - ### OBJ_ENTITY_ROOT

    public static final String OBJ_ENTITY_ROOT
    Since:
      4.1
    See Also:
      - Constant Field Values

  - ### DB_ENTITY_ROOT

    public static final String DB_ENTITY_ROOT
    Since:
      4.1
    See Also:
      - Constant Field Values

  - ### PROCEDURE_ROOT

    public static final String PROCEDURE_ROOT
    Since:
      4.1
    See Also:
      - Constant Field Values

  - ### DATA_MAP_ROOT

    public static final String DATA_MAP_ROOT
    Since:
      4.1
    See Also:
      - Constant Field Values

  - ### JAVA_CLASS_ROOT

    public static final String JAVA_CLASS_ROOT
    Since:
      4.1
    See Also:
      - Constant Field Values

  - ### name

    protected String name

  - ### type

    protected String type

  - ### dataMap

    protected DataMap dataMap

  - ### root

    protected Object root

  - ### properties

    protected Map<String,String> properties

- ## Constructor Details

  - ### QueryDescriptor

    protected QueryDescriptor(String type)

- ## Method Details

  - ### selectQueryDescriptor

    public static SelectQueryDescriptor selectQueryDescriptor()
    Creates new SelectQuery query descriptor.

  - ### sqlTemplateDescriptor

    public static SQLTemplateDescriptor sqlTemplateDescriptor()
    Creates new SQLTemplate query descriptor.

  - ### procedureQueryDescriptor

    public static ProcedureQueryDescriptor procedureQueryDescriptor()
    Creates new ProcedureQuery query descriptor.

  - ### ejbqlQueryDescriptor

    public static EJBQLQueryDescriptor ejbqlQueryDescriptor()
    Creates new EJBQLQuery query descriptor.

  - ### descriptor

    public static QueryDescriptor descriptor(String type)
    Creates query descriptor of a given type.

  - ### getName

    public String getName()
    Returns name of the query.

  - ### setName

    public void setName(String name)
    Sets name of the query.

  - ### getType

    public String getType()
    Returns type of the query.

  - ### setType

    public void setType(String type)
    Sets type of the query.

  - ### getDataMap

    public DataMap getDataMap()

  - ### setDataMap

    public void setDataMap(DataMap dataMap)

  - ### getRoot

    public Object getRoot()
    Returns the root of this query.

  - ### setRoot

    public void setRoot(Object root)
    Sets the root of this query.

  - ### getProperties

    public Map<String,String> getProperties()
    Returns map of query properties set up for this query.

  - ### getProperty

    public String getProperty(String name)
    Returns query property by its name.

  - ### setProperties

    public void setProperties(Map<String,String> properties)
    Sets map of query properties for this query.

  - ### setProperty

    public void setProperty(String name, String value)
    Sets single query property.

  - ### buildQuery

    public Query buildQuery()
    Assembles Cayenne query instance of appropriate type from this descriptor.

  - ### acceptVisitor

    public <T> T acceptVisitor(ConfigurationNodeVisitor<T> visitor)
    Specified by:
      `acceptVisitor` in interface `ConfigurationNode`

  - ### encodeAsXML

    public void encodeAsXML(XMLEncoder encoder, ConfigurationNodeVisitor delegate)
    Description copied from interface: `XMLSerializable`
    Prints itself as XML to the provided XMLEncoder.
    Specified by:
      `encodeAsXML` in interface `XMLSerializable`