Inverse References Involving Runtime Dynamic Properties
JADE inverse references are used to define relationships between classes. For details about using the JADE development environment to define a relationship, see "
A relationship can also be defined using runtime dynamic properties as the inverse references. For example, a one‑to‑many relationship (one customer has many appointments) could be established between the Customer class and Appointment class, as shown in the following diagram.
The runtime dynamic properties implementing the relationship are allAppointments, which is an exclusive collection property in a dynamic property cluster associated with the Customer class, and myCustomer, which is a property in a dynamic property cluster associated with the Appointment class.
The Property class method addDynamicInverse, which has the following signature, adds an inverse between the receiving dynamic property and the dynamic property specified in the property parameter.
addDynamicInverse(property: Property; mode: Character; kind: Character): Property subschemaFinal, updating, abstract;
This method returns a reference to the receiving dynamic property with the inverse added. Note that when the first inverse is added, this will be different from the receiver.
The property parameter must identify a compatible dynamic property; for example, if the type of the property is a
If instances of the class of either dynamic property exist and the dynamic properties have non-null values, the inverse relationship is not validated or populated when the inverse definition is added.
The values for the mode parameter are defined by the following ExplicitInverseRef class constants.
-
UpdateMode_Automatic (2)
-
UpdateMode_Automatic_Deferred (4)
The operation is executed when the transaction successfully commits.
-
UpdateMode_ManAuto (1)
-
UpdateMode_ManAuto_Deferred (5)
The operation is executed when the transaction successfully commits.
-
UpdateMode_Manual (0)
The values for the kind parameter are defined by the following ExplicitInverseRef class constants.
-
Kind_Child
-
Kind_Parent
-
Kind_Peer
The Property class removeDynamicInverse method, which has the following signature, removes an inverse reference between the dynamic property specified in the property parameter and the receiver.
removeDynamicInverse(property: Property): Property subschemaFinal, updating, abstract;
This method returns a reference to the receiving dynamic property with the inverse removed. Note that when the last inverse is removed, this will be different from the receiver.
In the following example, the runtime dynamic properties for each class are created, and then an inverse relationship is established between them.
vars custCluster, appCluster : JadeDynamicPropertyCluster; myCustomer, allAppointments : Property; begin beginTransaction; // Add 'allAppointments' custCluster := Customer.findDynamicPropertyCluster("CustomerCluster"); allAppoinments := custCluster.addExclusiveDynamicProperty("allAppointments", AppointmentDict); // Add 'myCustomer' appCluster := Appointment.findDynamicPropertyCluster("AppointmentCluster"); myCustomer := appCluster.addDynamicProperty("myCustomer", Customer, 0, 0.Byte); // Define inverse relationship myCustomer := myCustomer.addDynamicInverse(allAppointments, ExplicitInverseRef.UpdateMode_Manual, ExplicitInverseRef.Kind_Peer); commitTransaction; end;
Code that sets up inverse references must be executed before code that uses the inverses.
You cannot define inverses between runtime dynamic properties through the Class Browser.