Show TOC

Procedure documentationModeling a Query Model Class Locate this document in the navigation structure

 

On modeling a query model class, the IDE generates the QueryInput and QueryOutput relations for the query. This is displayed them in the Laptop UI Explorer. You can use the input or the result set of the query for context binding in the Mobile Project.

Prerequisites

You have created a query or a composite model class in the Mobile Project.

Procedure

  1. In the Mobile UI Explorer, click the query node with the secondary mouse button and choose Open Query/Composite Model Class Editor.

  2. Choose the Query tab.

  3. Enter details as specified in the table below:

    Field name

    Description

    User action and values

    Input Model Class

    Input object that defines the query input object

    1. Choose Query Model Class (Query Model Class)

      The Select Model Class dialog box appears.

    2. Select the required model class and choose Finish.

      Note Note

      • You can specify an imported or a composite model class as the input object or the output object. You can also treat a single model class as the input object and the output object, if required.

      • You must specify the Result Model Class before you proceed to the next step in this procedure.

      End of the note.

    Result Model Class

    Output object that defines the result set of the query

    -

    BI-DIRECTIONAL

    Select this option to allow navigation of the query result set in both directions.

    This option is enabled by default.

    Recommendation Recommendation

    We recommend that you select this option to improve performance during the backward movement of the data set.

    End of the recommendation.

    DISTINCT

    Select this option to retrieve only unique rows in the query result set.

    Note Note

    This applies to the result set of a join query only.

    End of the note.

    This option is disabled by default.

    Note Note

    The IDE allows you to enter aliases, filter conditions, and sort conditions for the query after you specify the Result Model Class.

    End of the note.
  4. Enter the conditions for the query, as specified in the table below:

    Field name

    Description

    User action and values

    Alias

    Alias name for a model class

    Note Note

    You can refer to the alias in the SQL query code to create the filter and the sort conditions.

    End of the note.

    Enter alias names for the required model classes.

    Note Note

    You can use code assist to select the required model classes.

    End of the note.

    Syntax: Model Class Alias

    Example: ORDER$ROOT order

    Note Note

    You can enter alias names for multiple model classes, separated by a comma.

    End of the note.

    Add join conditions for relations

    Button to generate the join conditions

    Note Note

    The IDE enables this button after you specify the Result Model Class. If the query model classes contains model classes that are related, you can choose this button to generate the join conditions (SQL code) for the existing relationships.

    End of the note.

    Choose Add join conditions for relations.

    The IDE generates the join condition for the query. You can make changes to the join condition and create the filter condition for the query, as required

    Conditions

    SQL condition to filter the query result set

    Enter the required condition, for example, order.amount>:amount, where amount is a field in the input class.

    For information on the Query language operators and parameters, refer toQuery Language Reference

    Sort Conditions

    Sort order of the query result set

    Enter the sort order for multiple attributes, separated by a comma. The default sort order is ascending. Alternatively, you can select the attribute from the dropdown list.

    Syntax: Model Class.Attribute Sort Order

    Example: order.amount descending

  5. To compile the query, choose   File   Save.  

    The IDE compiles the query. If an error occurs, the IDE displays an error message and displays the query error text in red. You can make the required changes to the query and repeat this step to recompile.