Part D: Dictionary that Has a Member at Invalid Keys

If you run the erroneous repair from Exercise Six, Part A, it will prevent the automatic dictionary from being updated when a member’s key is changed.

If you change the key property of the member, dictionary maintenance will not occur so the member will be stored at the old, incorrect key value. You can then run a repair that resets the reference Product::myCompany. The end state then is one in which the problem is purely that a member is stored at an incorrect key.

  1. Ensure that existing errors have been corrected.

  2. Run the erroneous repair created in Part A.

  3. Run the following Workspace script to alter the key property values of the first instance of Product.

    beginTransaction;
        Product.firstInstance.productDescription := "Box of screws";
    commitTransaction;
  4. Obtain the fix to reset Product::myCompany, by running the following script.

    vars
        fixLine : String;
    begin
        fixLine := "FIX1: set " & Product.firstInstance.getOidString
                    & " myCompany " & Company.firstInstance.getOidString;
        write fixLine;
    end;

    The form of the fix should be as follows.

    FIX1: set 2975.1 myCompany 2973.1
  5. Run the repair constructed from the output of the previous step.

    Note that attempting to retrieve the first product, a box of screws, via the key value "Box of screws" results in a null object referenced being returned.

    Company.firstInstance.allMyProducts.getAtKey("Box of screws")

    Conversely, attempting to retrieve a "Box of nails" results in a "Box of screws" being returned.

  6. Run the Logical Certifier in analysis mode. This anomaly will be reported in the following manner.

    ‑‑‑‑ Errors for LogCertTester::Company ‑‑‑‑‑‑‑‑‑‑‑‑‑‑
    *** Error 3: Collection contains object at invalid keys
        AllProductsByDescription/2976.1.2973.2.1 Company::allMyProducts contains Product/2975.1 at invalid keys (2976.1.2973.2.1 created 01 January 1970, 12:00:00, parent 2973.1 created 05 August 2009, 16:37:59)
    FIX1: rebuild 2976.1.2973.2.1

After running the repair, the first product will be accessible via its "Box of screws" key value.

The Logical Certifier will also report a second error, stating that the Product instance cannot be found in the collection. The nature of the corresponding fix depends on the update mode specified for the inverse. This second fix will not be run, however, since its execution is conditional upon still being unable to find the product in the collection, and the rebuild fix will be run first to address this. If an error prevents the first fix from being run, the second fix will then be run and the update mode determines the final outcome. This is the subject of the next exercise.