Skip Headers
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3)
B13593-01
  Go To Documentation Library
Home
Go To Product List
Solution Area
Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

Step 5: Using Advanced Descriptor Properties

In the Employee tutorial project, you will explore several of the TopLink advanced descriptor properties. This step includes exercises on using:

Inheritance

In reviewing the tutorial object model (see Figure 16-1), notice that the Project class is extended by two subclasses: SmallProject and LargeProject. These subclasses inherit characteristics from the parent class.

To specify inheritance in TopLink Workbench, first configure inheritance attributes of the parent class and then configure the inheritance attributes of each of its derived child class.

Root Parent Class

Use this procedure to specify that Project is the root parent descriptor in the hierarchy.

  1. Right-click the Project descriptor in the Navigator and select Select Advanced Properties from the context menu. The Select Advanced Properties dialog box appears.

  2. Select Inheritance and click OK. TopLink Workbench adds the Inheritance tab.

  3. Click the Inheritance tab. The Inheritance properties appear.

    Figure 17-27 Inheritance Tab, Parent Class

    Description of Figure 17-27  follows
    Description of "Figure 17-27 Inheritance Tab, Parent Class"

  4. Use the following information to complete each field on this tab:

    Field Description
    Read Subclasses on Query Select to allow TopLink to access the subclasses (LargeProject and SmallProject) in queries.
    Is Root Parent Descriptor Select to specify the Project descriptor as the root of the inheritance.
        Use Class Indicator Field Select PROJ_TYPE. This field contains the indicator value for each subclass.
            Use Class Indicator Dictionary Select Use Class Indicator Dictionary and select String as the Indicator Type. The class indicator field in the database table (PROJ_TYPE) is a string value.

Leave the other fields blank.

Child Class

Now you will identify each child class in the inheritance hierarchy (LargeProject and SmallProject subclasses) using this procedure:

  1. Right-click the LargeProject descriptor in Navigator and select Select Advanced Properties from the context menu. The Select Advanced Properties dialog box appears.

  2. Select Inheritance and click OK. TopLink Workbench adds the Inheritance tab.

  3. Click the Inheritance tab. The Inheritance properties appear.

    Figure 17-28 Inheritance Tab, Child Class

    Description of Figure 17-28  follows
    Description of "Figure 17-28 Inheritance Tab, Child Class"

  4. Use the following information to complete each field on this tab:

    Field Description
    Is Child Descriptor Specify that the LargeProject descriptor is a child descriptor and not the parent.
        Parent Descriptor Select the Project descriptor.

    Leave the other fields blank.

  5. Repeat this procedure for the SmallProject descriptor.

Indicator Values

To complete the inheritance, you must select which children to include in the inheritance hierarchy, using this procedure:

  1. Select the Project descriptor in the Navigator. Its properties appear in the Editor.

  2. Click the Inheritance tab. The Inheritance properties appear.

    Figure 17-29 Inheritance Tab, Indicator Values

    Description of Figure 17-29  follows
    Description of "Figure 17-29 Inheritance Tab, Indicator Values"

  3. Select to Include the LargeProject descriptor and click Edit. The Enter an Indicator Value dialog box appears.

  4. In the Indicator Value field, type L and click OK.

  5. Repeat steps 34 to include the SmallProject descriptor. Use S as the indicator value.

  6. Uncheck the Include column for the Project descriptor: because it is an abstract class, it does not require an indicator value.

  7. Save button.
    Click Save to save the project.

Locking Policy

In this tutorial project, each employee's project information (the Project class) uses optimistic locking based on version locking. To specify this locking policy, use this procedure:

  1. Select the Project descriptor in the Navigator.

  2. Click the Locking tab. The Locking tab appears.

  3. Use the following information to complete each field on this tab:

    Field Description
    Optimistic Locking Specify that this descriptor uses optimistic locking (instead of pessimistic locking).
        By Version Specify that this descriptor is locked by version (instead of by fields).
          Database Field Select the VERSION database field. TopLink will lock the descriptor based on the version of this database field.
          Version Locking Specify that this locked by version number (instead of time stamp).
          Store Version in Cache Specify that TopLink should store the version locking information in the cache.

  4. Repeat this procedure to implement locking for the Employee descriptor.

  5. Click Save to save the project.

Named Queries

To create a simple query to find all employees whose telephone number includes a specific area code, use this procedure:

  1. Select the PhoneNumber descriptor in the Navigator. Its properties appear in the Editor.

  2. Click the Queries tab. The Queries tab appears, containing three subtabs.

  3. Click the Named Queries subtab.

  4. Click Add to create a new named query. In the Add Named Query dialog box, leave the Type as ReadObject, type localNumbers in the Name field, and click OK. TopLink Workbench adds the query.

  5. Select the newly created localNumbers query. In the Parameters area of the General tab of the Named Queries tab, click Add. The Add Query Parameter dialog box appears.

    Figure 17-31 General Tab on Named Queries Subtab of the Queries Tab

    Description of Figure 17-31  follows
    Description of "Figure 17-31 General Tab on Named Queries Subtab of the Queries Tab"

  6. In the Name field of the Add Query Parameter dialog box, type ID. To configure the Type, click Browse. The Choose Class dialog box appears.

    Figure 17-32 Add Query Parameter Dialog Box

    This illustration shows the Add Query Parameter dialog.
  7. In the Choose a class field of the Choose Class dialog box, type String. In the Package area, select java.lang and click OK. TopLink Workbench adds the parameter.

    Figure 17-33 Choose Class Dialog Box

    This illustration shows the Choose Class dialog.
  8. Click the Selection Criteria subtab on the Names Queries subtab of the Queries tab. The Selection Criteria subtab appears.

    Figure 17-34 Selection Criteria Tab on Queries Tab

    Description of Figure 17-34  follows
    Description of "Figure 17-34 Selection Criteria Tab on Queries Tab"

  9. Select Expression as the Type to create a TopLink expression for this query, and click Edit. The Expression Builder dialog box appears.

  10. Click Add to create a new expression. TopLink Workbench adds the expression node.

    Figure 17-35 Expression Builder Dialog Box

    Description of Figure 17-35  follows
    Description of "Figure 17-35 Expression Builder Dialog Box"

  11. Use the following information to enter data in each field on this dialog box:

    Field Description
    First Argument Click Edit and select the areaCode attribute.
    Operator Select EQUAL.
    Second Argument Select Literal. Select String as the Type, type 613 as the Value.

    This expression will find all employees whose telephone number has a 613 area code.

  12. On the Expression Builder dialog box, click OK. The Selection Criteria subtab of the Named Queries subtab now includes the expression.

  13. Save button.
    Click Save to save the project.