Re: optional 1:1 relation, how to?

From: Mike Kienenberger (mkienen..laska.net)
Date: Fri Mar 11 2005 - 08:59:46 EST

  • Next message: tnaki..ofthome.net: "open cayenne project error"

    =?iso-8859-1?Q? J=FCrgen=20Saar ?= <jsaa..eb.de> wrote:
    > Hi,
    >
    > I have some Entities that have optional informations attached via a 1:1
    relation.
    > If I insert such an entity, and for the actual object there is no
    > such additional information, the validation fails
    > with the error-message "relAddtional is required"
    >
    > Is there a way to configure a 1:1 relation as optional (like an outer
    join)

    Change "mandatory" to false for your dbAttribute in the Cayenne modeler.

    Ie, assuming your object.relAddtional() relationship is based on the value
    of the OBJECT.REL_ADDITIONAL field, go to OBJECT (not object) and select
    attribute tab.

    Alternately, you can go in and just edit the DataMap.xml file and change (or
    remove) the value of mandatory directly.

    For example, here's what it looks like for creditCard() to be optional on my
    PaymentMethod object. Note that since there is no "isMandatory" attribute
    on PAYMENT_METHOD.CREDIT_CARD_ID, it defaults to false.

            <db-relationship name="creditCard" source="PAYMENT_METHOD"
    target="CREDIT_CARD" toMany="false">
                    <db-attribute-pair source="CREDIT_CARD_ID" target="CREDIT_CARD_ID"/>
            </db-relationship>

            <db-entity name="PAYMENT_METHOD">
                    <db-attribute name="ACCOUNT_NUMBER" type="INTEGER" isMandatory="true"
    length="8"/>
                    <db-attribute name="CREDIT_CARD_ID" type="INTEGER" length="8"/>
                    



    This archive was generated by hypermail 2.0.0 : Fri Mar 11 2005 - 08:58:54 EST