Show TOC

Modeling a Query Model ClassLocate this document in the navigation structure

Prerequisites

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

Context

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.

Procedure


  1. In the Laptop 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

      The Select Model Class dialog box appears.

    2. Select the required model class and choose Finish.

      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.

    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

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

    DISTINCT

     

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

    Note

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

    This option is disabled by default.

    Note

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

  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

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

    Enter alias names for the required model classes.

    Note

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

    Syntax: Model Class Alias

    Example: ORDER$ROOT order

    Note

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

    Add join conditions for relations

    Button to generate the join conditions

    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.

    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 to Query 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 Start of the navigation path File Next navigation step Save. End of the navigation path

    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.