Modeler doesn't generate/validate reverse relationships from EOModel [WAS Re: NullPointerException in QueryUtils$ExpressionTranslator.reverseDbPath(ObjEntity, String)]

From: Mike Kienenberger (mkienen..laska.net)
Date: Mon Oct 06 2003 - 14:07:44 EDT

  • Next message: Mike Kienenberger: "Re: NullPointerException in QueryUtils$ExpressionTranslator.reverseDbPath(ObjEntity, String)"

    Andrus Adamchik <andru..bjectstyle.org> wrote:
    > Yeah, missing reverse DB relationship will most definitely case this
    > problem.

    > Now why it is missing is another question. It needs further
    > investigation with your source EOModel. Can you reproduce it? I mean -
    > import EOModel again, and see if the new resulting map is missing the
    > relationship as well.

    Yes, I've imported the EOModel into a new model, and I see the same problems.

    I'll try to see if I can reproduce it with a simplified version of my model (just the PendingPayment and PaymentHistory entities).

    Yep. Here's my simplified model, converted.

    <?xml version="1.0" encoding="UTF-8"?>
    <data-map project-version="1.0">
            <db-entity name="PAYMENT_HISTORY">
                    <db-attribute name="ATTRIBUTE" type="INTEGER" length="8"/>
                    <db-attribute name="PAYMENT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="8"/>
            </db-entity>
            <db-entity name="PENDING_PAYMENT">
                    <db-attribute name="PAYMENT_ID" type="INTEGER" isMandatory="true" length="8"/>
                    <db-attribute name="PENDING_PAYMENT_ID" type="INTEGER" isPrimaryKey="true" isMandatory="true" length="8"/>
            </db-entity>
            <obj-entity name="PaymentHistory" className="PaymentHistory" dbEntityName="PAYMENT_HISTORY">
                    <obj-attribute name="attribute" type="java.lang.Integer" db-attribute-path="ATTRIBUTE"/>
            </obj-entity>
            <obj-entity name="PendingPayment" className="PendingPayment" dbEntityName="PENDING_PAYMENT">
            </obj-entity>
            <db-relationship name="paymentHistory" source="PENDING_PAYMENT" target="PAYMENT_HISTORY" toDependentPK="false" toMany="false">
                    <db-attribute-pair source="PAYMENT_ID" target="PAYMENT_ID"/>
            </db-relationship>
            <obj-relationship name="paymentHistory" source="PendingPayment" target="PaymentHistory" toMany="false">
                    <db-relationship-ref source="PENDING_PAYMENT" target="PAYMENT_HISTORY" name="paymentHistory"/>
            </obj-relationship>
    </data-map>

    One thing that's true of this model is that, in my EOModel, the relationship is only defined from PendingPayment to PaymentHistory. There's no explicitly defined relationship from PaymentHistory to PendingPayment. It's not required by EOF that relationship have reverses.

    The import function needs to either correctly create the reverse relationships or to flag them to be corrected.

    Also, the Validate Project command did not flag the missing reverse relationships.

    Actually, it didn't flag the missing DataNode either.

    I'm attaching my SimpleEOModel.eomodeld.zip file.

    -Mike

    [SimpleEOModel.eomodeld.zip]



    This archive was generated by hypermail 2.0.0 : Mon Oct 06 2003 - 14:07:23 EDT