Re: Conditional relationship mapping?

From: Aristedes Maniatis (ar..sh.com.au)
Date: Tue Mar 31 2009 - 06:56:55 EDT

  • Next message: Joseph Schmidt: "Re: Conditional relationship mapping?"

    On 29/03/2009, at 4:28 AM, Joseph Schmidt wrote:

    >
    > Is it possible for Cayenne(and the Modeler) to map conditional
    > relationships?
    >
    > I have a table, e.g. "tag" that relates to too many other tables,
    > but one row is always related only to one table. This is done by
    > having
    > instead of many foreign keys columns, just with 2 in a generic way:
    > - 'related_table' contains the name of the target table, and
    > - 'related_row_id' is the 'id' of the row in the target table.
    >
    > I see this scenario in many schemes lately, where at least 3 or 4
    > tables behave like the above "tag" table.
    >
    > Is it possible to map efficiently such a scenario with Cayenne(and
    > the modeler)? If it is, how?

    Choice 1:
    This looks a lot like inheritance. Explore the various options
    available to you there, particularly in Cayenne 3. This is the
    'proper' way to do it. Most of the time.

    Choice 2:
    Just do exactly what you are doing and fake the relationships.
    Subclass CayenneContext so that you can create the appropriate setters
    and getters to make this all work. We do this ourselves and I might be
    able to dig up some code if you get stuck.

    Ari Maniatis

    -------------------------->
    ish
    http://www.ish.com.au
    Level 1, 30 Wilson Street Newtown 2042 Australia
    phone +61 2 9550 5001 fax +61 2 9550 4001
    GPG fingerprint CBFB 84B4 738D 4E87 5E5C 5EFA EF6A 7D2E 3E49 102A



    This archive was generated by hypermail 2.0.0 : Tue Mar 31 2009 - 06:58:46 EDT