Query builder APIs
The query builder APIs provide support for retrieving information from PolicyCenter application databases.
The API framework models features of SQL SELECT statements to make
object-oriented Gosu queries. The query builder APIs support many, but not all, features of
the SQL SELECT statement.
Supported SQL features in query builder APIs
Query builder APIs provide functionality similar to these features of SQL
SELECT statements.
|
Keyword or clause in SQL |
Equivalent in query builder APIs example |
Purpose |
|---|---|---|
|
|
In Gosu:
In Java:
|
Begins a query. Generally, the results of a query are a set of object references to selected entity instances. |
|
|
|
Declares the primary source of data. |
|
|
|
Eliminates duplicate items from the results. |
|
column1 |
|
Produces a result that contains a set of name/value pairs, instead of a set of entity instances. |
|
|
|
Joins a dependent source of information to the primary source, based on a related column or field. |
|
|
|
Fetches information that meets specified criteria. |
|
|
|
Sort results by specific columns or fields. |
|
|
Implied by aggregate functions on fields |
Return results grouped by common values in a field. |
|
|
|
Return results based on values from aggregate functions. |
|
|
|
Combine items fetched by two separate queries into a single result. Note: You cannot use the union method on query objects passed as
arguments to the subselect method.
|
|
|
|
Limit the results to the first row, after grouping and ordering. |
|
|
|
Limit the results to the first int number of rows at the top, after grouping and ordering. These query builder API methods provide similar functionality in a portable way. |
Unsupported SQL features in query builder APIs
Query builder APIs provide have no equivalent for these features of SQL
SELECT statements. PolicyCenter never
generates SQL statements that contain these keywords or clauses.
|
Keyword or clause in SQL |
Meaning in SQL |
Why the APIs do not support it |
|---|---|---|
|
|
Declares the tables in a join query, beginning with the primary source of information on the left and proceeding with dependent sources of information towards the right. |
|
|
|
Removes items fetched by a query that are in the results fetched by a second query. |
This SQL feature is seldom used. |
|
|
Reduce items fetched by two separate queries to those items in both results only. |
Query intersection often causes a performance problem. A better choice is to use
a more efficient query type. For example, if both sides of the
|
See also
- Building a simple query
- Making an inner join with the foreign key on the right
- Working with row queries
- Joining a related entity to a query
- Restricting a query with predicates on fields
- Ordering results
- Applying a database function to a column
- Accessing the first item in a result
- Setting the page size for prefetching query results
- Determining if a result will return too many items
