Class SelectQueryDescriptor
java.lang.Object
org.apache.cayenne.map.QueryDescriptor
org.apache.cayenne.map.SelectQueryDescriptor
- All Implemented Interfaces:
ProjectNode, XMLSerializable
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe kind of the objects that a select query fetches, seegetResultKind(). -
Field Summary
Fields inherited from class QueryDescriptor
cacheGroup, cacheStrategy, DATA_MAP_ROOT, dataMap, DB_ENTITY_ROOT, fetchingDataRows, JAVA_CLASS_ROOT, name, OBJ_ENTITY_ROOT, pageSize, PROCEDURE_ROOT, root, statementFetchSize -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFluentSelect<?, ?> Returns the query with its "$name" parameters unbound.FluentSelect<?, ?> buildQuery(Map<String, ?> parameters) Returns the query with its "$name" parameters bound to the values from the map.voidencodeAsXML(XMLEncoder encoder, ProjectNodeVisitor<?> delegate) Prints itself as XML to the provided XMLEncoder.Deprecated, for removal: This API element is subject to removal in a future version.Returns the names of the "$name" parameters of the query, in the order of their first occurrence.FluentSelect<?, ?> Returns the parsed query String with its "$name" parameters unbound.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, seegetParsedQuery()getQl()Returns the query String, exactly as it was set.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, seegetParsedQuery()Returns the kind of the objects that the query fetches.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.booleanReturns whether this query selects columns, and not the root objects.booleanReturns whether this query is rooted in a DbEntity.booleanDeprecated, for removal: This API element is subject to removal in a future version.since 5.0, as the query is defined by a String, seegetParsedQuery()booleanisValid()Returns whether the query String can be parsed.voidSets the query String.voidNot supported, as the root is defined by the "from" clause of the query String.Methods inherited from class QueryDescriptor
acceptVisitor, getCacheGroup, getCacheStrategy, getDataMap, getName, getPageSize, getStatementFetchSize, isFetchingDataRows, setCacheGroup, setCacheStrategy, setDataMap, setFetchingDataRows, setName, setPageSize, setStatementFetchSize
-
Constructor Details
-
SelectQueryDescriptor
public SelectQueryDescriptor()
-
-
Method Details
-
getQl
-
setQl
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
Returns the parsed query String with its "$name" parameters unbound. The returned query is shared and must not be modified or run, usebuildQuery(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
Returns the kind of the objects that the query fetches.- Since:
- 5.0
-
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
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:
getRootin classQueryDescriptor
-
setRoot
Not supported, as the root is defined by the "from" clause of the query String.- Overrides:
setRootin classQueryDescriptor
-
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, seegetParsedQuery() -
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, seegetParsedQuery()Returns the "where" clause of the query, or null if it has none or can't be parsed. -
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, seegetParsedQuery()Returns a list of the orderings of the query, empty if it has none or can't be parsed. -
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, seegetParsedQuery()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
Returns the query with its "$name" parameters unbound.- Specified by:
buildQueryin classQueryDescriptor
-
buildQuery
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:
buildQueryin classQueryDescriptor- Since:
- 5.0
-
encodeAsXML
Description copied from interface:XMLSerializablePrints itself as XML to the provided XMLEncoder.
-
getParsedQuery()