Querying Example (OQL)

Querying Example (OQL)

With OQL querying, you can combine data from multiple regions and drill down into nested region objects, extracting only the data points you need.

OQL is similar to SQL but it works with objects. You can also use indexing to optimize your query performance.

Running the Example

This example creates an example region with data and then runs a handful of queries against it. The first query selects everything from the region so you can see all data the queries are run against.

Note: To run this example, you must have terminal sessions configured for the QuickStart examples, as described in Setting Up Your Environment for Running the Examples.

In a single session, run the example:

$ java -cp "$GEMFIRE/SampleCode/quickstart/classes:$GEMFIRE/lib/server-dependencies.jar" quickstart.Querying 

Example Source Files

Program and cache configuration source files:

Table 1. Cache configuration files, located in SampleCode/quickstart/xml
Querying.xml Initializes a region with sample Portfolio data for querying.
Table 2. Java program files, located in SampleCode/quickstart/quickstart
Querying.java Demonstrates querying on a set of data in a region.
Portfolio.java A stock portfolio that consists of multiple Position objects that represent shares of a stock.
Position.java Represents shares of stock held in a portfolio.
Related Topics

Related Javadocs

  • com.gemstone.gemfire.cache.query