Querying with OQL
This section provides a high-level introduction to VMware GemFire querying such as building a query string and describes query language features.
VMware GemFire provides a SQL-like querying language that allows you to access data stored in VMware GemFire regions. Since VMware GemFire regions are key-value stores where values can range from simple byte arrays to complex nested objects, VMware GemFire uses a query syntax based on OQL (Object Query Language) to query region data. OQL and SQL have many syntactical similarities, however they have significant differences. For example, while OQL does not offer all of the capabilities of SQL like aggregates, OQL does allow you to execute queries on complex object graphs, query object attributes and invoke object methods.
The syntax of a typical VMware GemFire OQL query is:
[IMPORT package] SELECT [DISTINCT] projectionList FROM collection1, [collection2, …] [WHERE clause] [ORDER BY order_criteria [desc]]
Therefore, a simple VMware GemFire OQL query resembles the following:
SELECT DISTINCT * FROM /exampleRegion WHERE status = ‘active’
An important characteristic of VMware GemFire querying to note is that by default, VMware GemFire queries on the values of a region and not on keys. To obtain keys from a region, you must use the keySet path expression on the queried region. For example,
For those new to the VMware GemFire querying, see also the VMware GemFire Querying FAQ and Examples.