Ordering methods of the query builder API
The Query builder API supports the following ordering methods on result objects.
|
Method |
Description |
|---|---|
|
orderBy |
Clears all previous ordering, and then orders results by the specified column in ascending order. |
|
orderByDescending |
Clears all previous ordering, and then orders results by the specified column in descending order. |
|
thenBy |
Orders by the specified column in ascending order, without clearing previous ordering. |
|
thenByDescending |
Orders by the specified column in descending order, without clearing previous ordering. |
The ordering methods all take an object that implements the IQuerySelectColumn interface in the gw.api.database package as their one argument. To create this object, use the following syntax.
QuerySelectColumns.path(Paths.make(PrimaryEntity#SimpleProperty))
The Paths.make method yields an object access path from the primary entity to a simple, non-foreign-key, database-backed property. Gosu checks property names against column names in the Data Dictionary. To specify a path to a property on a dependent table, specify a foreign-key property to the dependent table on the previous table parameter.
For example, the following Gosu code specifies
a simple property, the PostalCode
on an Address instance.
QuerySelectColumns.path(Paths.make(Address#PostalCode))
See also
