Populating one-to-many associations with objects

If you draw a one-to-many directed association between a class A and a class B, and create an object of A and several objects of B, you can connect the objects with a link that instantiates the association.

About this task

The code generated by the product for such a relationship creates a container class for the one-to-many relationship in A, and creates objects of A and B. However, it does not necessarily populate the container for A with the objects of B. When you model a relationship as one-to-n, the product instantiates n objects in the container. The product populates only associations with known multiplicity, and graphically shows when an association instance, or link, actually exists and when it does not.

You can populate a one-to-many container by creating the objects in source code and adding them to the container. However, you cannot model a generic one-to-many relationship and populate it with an unknown number of diagrammatically modeled objects. Therefore, it is not possible to populate a one-to-many relationship between classes drawn in one object model diagram with objects drawn in another object model diagram.


Feedback