Show TOC

Defining Business Object AssociationsLocate this document in the navigation structure

Use

You can create associations between business objects. Association of business object nodes is a way to specify model-level dependency between two business object nodes. At runtime this is  implemented as a relation between the master tables of the two business objects nodes. The association gives you a way to retrieve related business object node instances of a particular business object node. Once you model an association in Composite Application Explorer and generate the code, there is a set of methods ( set(), get(), add() and remove() ) available in the business object nodes service interface to manage this association at runtime. Another way to use association is to model findBy operations that involve attributes of the associated business object nodes.

Procedure
  1. Open the Associations tab page of the business object editor for which you want to create an association.
  2. In the Available Business Object Nodes tree, select the business object node you want to associate.

    Choose with the quick info text Add Association.

  3. Optional: You can enable permission propagation for the association you have created. To do that, select it and set the Propagate Permissionparameter to true in thePropertiesview.
  4. Make the association bi-directional or unidirectional. To do that, enable or disable the Bi-Directionalindicator on the Associationtab page.
    • unidirectional -  the association has a target and a source business object node.
    • bi-directional - association has two sides. This way you allow the navigation, management, and usage of query operations for this association from both sides of the associated business objects.
      Note

      You can change the values of the Nameand Cardinalityfields for the target business object node on its Associationstab page.

      CAF automatically creates associations for both source and target business object nodes in the Composite Application Explorerview.

  5. Choose the type of your association. You have the following options regarding the type of the association:
    • Child-parent associations between business objects.

      If the parent business object node is deleted, the child business object node is deleted as well. To create a parent-child association, in the Composite Application Explorer, click the node of the business object and choose New BO Node. Choose the newly created business object node and choose with the quick info text Add Association.

    • Cross-business object associations.

      This way, if you delete the source business object, the target business object node of the association is not deleted. To create a cross-business object node association, choose a business object node with a different root node and choose with the quick info text Add Association.

    • Internal business object node associations.
Result

The business object node hasas a new association.

To remove an association, select it and choose with the quick info text Delete Association.

Example

You may have a business object node named Department that has an association to another business object node Employee. Then you can set the cardinality to be NONE_TO_MANY (that implies a collection) and you can get all the employees that currently work in a particular department. Three tables are generated at runtime - two for business object nodes and one table for the multiple association between them.