The processing cycle of a query
Two types of objects drive the processing cycle of PolicyCenter queries:
- A query object
- Specifies which PolicyCenter entity instances to fetch from the application database
- A select object
- Specifies how to order and group selected entity instances
The processing cycle of a PolicyCenter query follows these high-level steps:
- Invoke the static gw.api.database.Query.make(EntityType) method, which creates a query object.
- Refine your query object with restrictions.
- Invoke the select method on your query object, which creates a select object.
- Refine your select object by ordering the selected items.
- Iterate your select object with methods that the
java.lang.iterable<T>interface defines or with aforloop.
The following diagram illustrates the processing cycle of a query.
The query builder APIs send queries to the application database when your code accesses information from the result set, not when your code calls the select method. Although your code seems to order results after fetching data, the query is not performed until you start to access the result set. The application database orders the results while fetching data. Any action that you take on result objects to return information, such as getting result counts or starting to iterate the result, triggers query execution in the application database.
