Class SelectQueryDescriptor

java.lang.Object
org.apache.cayenne.map.QueryDescriptor
org.apache.cayenne.map.SelectQueryDescriptor
All Implemented Interfaces:
ProjectNode, XMLSerializable

public class SelectQueryDescriptor extends QueryDescriptor
A mapped select query, defined by a String in the syntax of ObjectSelect.parse(String, Object...). The root of the query is defined by its "from" clause, so it is null while the String can't be parsed. The settings that the String has no syntax for (caching, page size, etc.) are the properties of the descriptor.
Since:
4.0
  • Constructor Details

    • SelectQueryDescriptor

      public SelectQueryDescriptor()
  • Method Details

    • getQl

      public String getQl()
      Returns the query String, exactly as it was set.
      Since:
      5.0
    • setQl

      public void setQl(String ql)
      Sets the query String. The String is stored as is, and is not validated until the query is parsed.
      Since:
      5.0
    • isValid

      public boolean isValid()
      Returns whether the query String can be parsed.
      Since:
      5.0
    • getParsedQuery

      public FluentSelect<?,?> getParsedQuery()
      Returns the parsed query String with its "$name" parameters unbound. The returned query is shared and must not be modified or run, use buildQuery(Map) to get a query to run.
      Throws:
      ExpressionException - if the String is empty or can't be parsed
      Since:
      5.0
    • isColumnQuery

      public boolean isColumnQuery()
      Returns whether this query selects columns, and not the root objects.
      Since:
      5.0
    • isDbQuery

      public boolean isDbQuery()
      Returns whether this query is rooted in a DbEntity.
      Since:
      5.0
    • getResultKind

      public SelectQueryDescriptor.ResultKind getResultKind()
      Returns the kind of the objects that the query fetches.
      Since:
      5.0
    • getParameterNames

      public Set<String> getParameterNames()
      Returns the names of the "$name" parameters of the query, in the order of their first occurrence.
      Throws:
      ExpressionException - if the query String can't be parsed
      Since:
      5.0
    • getRoot

      public Object getRoot()
      Returns the root of the query defined by its "from" clause: an ObjEntity, a DbEntity or, if no such entity is mapped, its name. Returns null if the query String can't be parsed.
      Overrides:
      getRoot in class QueryDescriptor
    • setRoot

      public void setRoot(Object root)
      Not supported, as the root is defined by the "from" clause of the query String.
      Overrides:
      setRoot in class QueryDescriptor
    • isDistinct

      @Deprecated(since="5.0", forRemoval=true) public boolean isDistinct()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.0, as the query is defined by a String, see getParsedQuery()
    • getQualifier

      @Deprecated(since="5.0", forRemoval=true) public Expression getQualifier()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.0, as the query is defined by a String, see getParsedQuery()
      Returns the "where" clause of the query, or null if it has none or can't be parsed.
    • getOrderings

      @Deprecated(since="5.0", forRemoval=true) public List<Ordering> getOrderings()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.0, as the query is defined by a String, see getParsedQuery()
      Returns a list of the orderings of the query, empty if it has none or can't be parsed.
    • getPrefetchesMap

      @Deprecated(since="5.0", forRemoval=true) public Map<String,Integer> getPrefetchesMap()
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 5.0, as the query is defined by a String, see getParsedQuery()
      Returns a map of the prefetch paths of the query with their semantics, empty if it has none or can't be parsed.
      Since:
      4.1
    • buildQuery

      public FluentSelect<?,?> buildQuery()
      Returns the query with its "$name" parameters unbound.
      Specified by:
      buildQuery in class QueryDescriptor
    • buildQuery

      public FluentSelect<?,?> buildQuery(Map<String,?> parameters)
      Returns the query with its "$name" parameters bound to the values from the map. The smallest condition that contains a parameter missing from the map is pruned.
      Specified by:
      buildQuery in class QueryDescriptor
      Since:
      5.0
    • encodeAsXML

      public void encodeAsXML(XMLEncoder encoder, ProjectNodeVisitor<?> delegate)
      Description copied from interface: XMLSerializable
      Prints itself as XML to the provided XMLEncoder.