New Issues

Let’s learn about some of the new issues that we may face in the bidirectional application.

We'll cover the following

Issues to deal with

Compared to the Unidirectional Association App, we have to deal with a few new technical issues:

  1. We define the derived inverse reference properties, such as Publisher::/publishedBooks, without a check operation and without a set operation.
  2. We also need to maintain the derived inverse reference properties by maintaining the derived (sets of) inverse references that form the collection value of a derived inverse reference property. In particular, this requires that:
    • Whenever the value of a single-valued leader reference property is initialized or updated with the help of a setter (a reference is assigned to a Publisher instance p to b.publisher for a Book instance b), an inverse reference has to be assigned or added to the corresponding value of the derived inverse reference property. For example, if b is added to p.publishedBooks. When the value of the leader reference property is updated and the derived inverse reference property is multi-valued, then the obsolete inverse reference to the previous value of the single-valued leader reference property needs to be deleted.
    • Whenever the value of an optional single-valued leader reference property is unset (we assign null to b.publisher for a Book instance b), the inverse reference needs to be removed from the corresponding value of the derived inverse reference property. For example, if b is removed from p.publishedBooks. This is done if the derived inverse reference property is multivalued. Otherwise, the corresponding value of the derived inverse reference property needs to be unset or updated.
    • Whenever a reference is added to the value of a multivalued leader reference property with the help of an add method (add an Author reference a to b.authors for a Book instance b), an inverse reference has to be assigned or added to the corresponding value of the derived inverse reference property. For example, if b is added to a.authoredBooks.
    • Whenever a reference is removed from the value of a multivalued leader reference property with the help of a remove method (remove a reference to an Author instance a from b.authors for a Book instance b), the inverse reference needs to be removed from the corresponding value of the derived inverse reference property. For example, if b is removed from a.authoredBooks. This is done if the derived inverse reference property is multivalued. Otherwise, the corresponding value of the derived inverse reference property needs to be either unset or updated.
    • Whenever an object with a single reference or with multiple references as the value of a leader reference property is destroyed (when a Book instance b with a single reference b.publisher to a Publisher instance p is destroyed), the derived inverse references have to be removed first. For example, if b is removed from p.publishedBooks.

When a new object is created with a one or more references as the value of a leader reference property, such as a new Book instance b with a single reference b.publisher, its setter or add method is invoked and takes care of the creation of derived inverse references.

Get hands-on with 1200+ tech skills courses.