ObjectExtender User's Guide and Reference

Creating one-to-many (1-M) relationships

The Bank sample uses a one-to-many relationship for the VapBankBranch and the VapAccount business objects. This topic explains how to create a one-to-many relationship using the ObjectExtender tools.

Do the following:

It was created as follows:

  1. Select New Association from the Associations menu.

    This launches the Association Editor.


    Figure pgs2d not displayed.

  2. In the Association name field, type BankBranch-Account.
  3. Define the two Class sections.
    1. In the left Class pane, select VapAccount.
    2. In the right Class pane, select VapBankBranch.
    3. Type branch for Role of VapBankBranch.
      • Select Navigable.

        This means VapBankBranch can be obtained from the VapAccount object.

    4. Type accounts for Role of VapAccount.
    5. Select Navigable.

      This means VapAccount can be obtained from the VapBankBranch object.

      Select Many. This sets the cardinality to zero-to-many (0:M). If a cardinality of one-to-many (1:M) is desired, select Required.

  4. Select OK.

You are now done with the Model Browser. The one-to-many relationship is defined.

Next, defining this relationship using schema semantics is shown. Finally, mapping the schema to the model is the last step for completing the persistence layer.

Do the following:

It was created as follows.

  1. Select Foreign Key Relationship from the Foreign_Keys menu.

    This launches the Foreign Key Relationship editor.


    Figure pgs2e not displayed.

  2. Type account-branch for the Name.
  3. Type R1 for the Physical Name.
  4. If a foreign key constraint does not exist on the database, make sure Constraint exists in database is not selected.
  5. Update the Relationship section:
    1. Select BRANCH for the Primary key table.

      The Primary key column (read-only) will be updated with the primary key from the table.

    2. Select ACCOUNT for the Foreign key table.

      In the Foreign key column, select the foreign key in the ACCOUNT table which corresponds to the branch, BRANCHNO.

  6. Select OK.

You are now done with the Schema Browser.

The last step in defining the persistence layer for the one-to-many relationship follows.

It was created as follows.

  1. Select Bank Sample from the Datastore Maps view, VapBankBranch from the Persistent Classes view, and BRANCH from the Table Maps view.
  2. Select Edit Property Maps from the Table_Maps menu.

    This launches the Property Map Editor.

  3. Click on the Associations tab.


    Figure pgs2f not displayed.

  4. Change the [Not Mapped] value of the accounts association to account-branch under Foreign Key Relationships.
  5. Select OK.

This concludes the persistence layer for the one-to-many relationship.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]