RQL is a textual query syntax, similar to SQL. It describes the set of conditions that must be matched by items of a particular item descriptor. The following is a simple RQL query that matches all items whose age property is greater than 30.

age > 30

Notice that the name of the item descriptor is not included in the RQL query. The item descriptor is usually implied by the context of the query’s use.

All of the standard comparison operators can be used, as well as logical operators like AND, OR, and NOT:

age > 30 AND (lastName = "jones" OR paymentOverdue = true)

Constants such as 30, true, or jones can represent numbers, boolean, or String values. String values are represented using Java syntax. They must be enclosed by quotes, and escape sequences for special characters or UNICODE characters must use Java escape syntax.

Note that properties such as age or lastName must be the property names used in the repository. For example, a database might have a column named phone, but that might be mapped to the repository property primaryPhoneNumber. An RQL query must use the repository’s property name primaryPhoneNumber, not the column name phone.

Also note that all RQL keywords (AND, OR, NOT, etc.) may be specified in either all upper-case or all lower-case. For example:

age > 30 and (lastName = "jones" or paymentOverdue = true)

RQL statements specify the conditions that an item must meet in order to be included in the result set. In addition, an RQL statement may specify other directives to be applied to the result set, including ordering of the results, or returning just a portion of the result set.

 
loading table of contents...