IBM Support

Initializing one-to-many association relation with named Objects

Question & Answer


Question

How to initialize one to many association relation with named Objects

Answer

When having a class related to an array of n objects through an association with multiplicity n, where n=1,2,3... , Rhapsody automatically initializes them under the initRelation().

However, considering a model having named objects instead of array of objects, Rhapsody does not initialize them because it cannot know which relation to initialize with which object.This is up to you to initialize them the way you desire.

There are two ways you can initialize these relations :

  • Create separate associations and links to each of the named Objects. (See attached screenshot : UsingSeparateLinks.JPG)
  • Manually add the initialization code inside the constructor. (See attached screenshot : ExplicitInitialization.JPG)

UsingSeparateLinks.JPGExplicitInitialization.JPG

[{"Product":{"code":"SSB2MU","label":"IBM Engineering Systems Design Rhapsody"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"General Information","Platform":[{"code":"PF033","label":"Windows"}],"Version":"7.5.0.1;7.5","Edition":"","Line of Business":{"code":"LOB59","label":"Sustainability Software"}}]

Product Synonym

Rational Rhapsody

Document Information

Modified date:
27 May 2022

UID

swg21405221