此内容没有您所选择的语言版本。
6.2. Creating Queries
There are two ways to create a JCR
Query
object. The first is by supplying a query expression and the name of the query language, and this can be done with the standard JCR API:
Before returning the
Query
, the hierarchical database finds a parser for the language given by the language
parameter, and uses this parser to create a language-independent object representation of the query. (Note that any grammatical errors in the expression result in an immediate exception.) This object representation is what JCR 2.0 calls the "Query Object Model", or QOM. After parsing, the hierarchical database embeds the QOM into the Query
object.
The second approach for creating a
Query
object is to programmatically build up the query using the QueryObjectModelFactory
. Again, this uses the standard JCR API. Here's a simple example:
Of course, the
QueryObjectModelFactory
can create lots variations of selectors, joins, constraints, and orderings. The hierarchical database fully supports this style of creating queries, and it even offers some very useful extensions (described below).