Re: Hierarchical relationship problems

From: Filip Balas (fbala..mail.com)
Date: Thu Apr 28 2005 - 18:04:17 EDT

  • Next message: tnaki..ofthome.net: "Re: Problems with cayenne, tapestry and postgres"

    Andrus,

    After reading the page, I realize that everything works as documented.
    However, I am wondering why the relationship MUST be many to many.
    Is it not trivial to make it work the same for one-to-many as it is for
    many-to-many?

    Just for the sake of the List, I will probably have to use the
    following solution:

    1) Make the relationship many-to-many
    2) In the non-Generated-POJO PhoneNumber I will override the methods
    addToEmployees and removeFromEmployees so that they throw an exception
    (this is to prevent other developers from accidentally using these
    methods.
    3) Create a get/setEmployee method which will use the generated-POJO
    _PhoneNumber to ensure that only one is ever assigned.

    I appologize for not reading the documentation in enough detail.

    Filip

    On 4/28/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    >
    > <obj-relationship name="phone_numbers" source="Location"
    > target="PhoneNumber" db-relationship-path="rel_ph_loc.phone_nums"/>
    >
    > <obj-relationship name="location" source="PhoneNumber"
    > target="Location" db-relationship-path="rel_ph_loc.location"/>
    >
    > The relationships above are flattened (i.e. they consist of multiple db
    > relationships -
    > http://objectstyle.org/cayenne/modelerguide/modeling-object-layer/flattenedrel.html)...
    > So this is exactly the case that I was talking about.... Now why are they
    > treated as read-only? My guess (without trying) is that join table columns
    > are not marked as PK:
    >
    > <db-entity name="IMV_location_phone_nums" schema="dbo">
    > <db-attribute name="location_id" type="INTEGER" length="10"/>
    > <db-attribute name="phone_id" type="INTEGER" length="10"/>
    > </db-entity>
    >
    > Andrus



    This archive was generated by hypermail 2.0.0 : Thu Apr 28 2005 - 18:04:22 EDT