RE: can Cayenne handle an inheritance model like this?...

From: Summers, John1 (john1.summer..iti.com)
Date: Thu Apr 01 2010 - 12:25:58 EDT

  • Next message: Nishant Neeraj: "Conditions when PersistenceState gets "hollow""

    Thanks Robert,

    Good point and I have made a stupid ommission in my description. In fact BASEENTITY has a column 'REF' on it which together with LINKID provides uniqueness:

    BASEENTITY
    ID=1, LINKID=100, REF='Trade'
    ID=2, LINKID=200, REF='Instr'
    (LINKID and REF together have a unique index on them)

    TRADE
    ID=100

    INSTR
    ID=200

    And in the current data access layer the DAO's actually work out which type of entity they are building and and provide the correct discriminator ('Trade', 'Instr', etc) for the sql statements to load in the data to the superclass.

    Cheers,
    John

    -----Original Message-----
    From: Robert Zeigler [mailto:robert.zeigle..oxanemy.com]
    Sent: 01 April 2010 17:05
    To: use..ayenne.apache.org
    Subject: Re: can Cayenne handle an inheritance model like this?...

    How do you ensure that you don't wind up with duplicated LINKID values? Eg, if TRADE.ID assigned based on the value of LINKID, or is LINKID assigned based on the value of TRADE.ID and/or INSTR.ID?

    Robert

    On Thu, Apr 1, 2010 at 10:49 AM, Summers, John1 <john1.summer..iti.com>wrote:

    > Hello Apache-Cayenne users,
    >
    > I am engaged on a project where we are trying to replace a messy
    > bespoke Data Access Layer with a more modern ORM framework. We have
    > been looking at Hibernate but it cannot handle our inheritance model.
    > I would like to ask if Cayenne can handle such a model because if it
    > can we will continue and make a full assessmet of Cayenne. I will describe the model to you now:
    >
    > Ok the database tables look like this:
    >
    > BASEENTITY
    > -ID
    > -LINKID
    >
    > TRADE
    > -ID
    >
    > INSTR
    > -ID
    >
    > And the Java object hierarchy is that BaseEntity is the superclass
    > with Trade and Instr (and others) as the subclass.
    >
    > Here's the rub...
    >
    > The ID fields on the 3 tables do NOT express a hierarchy. They are
    > unique to each table only. You cannot look up a Trade's BaseEntity by
    > using the trade ID and finding a matching LINKID in BaseEntity.
    >
    > The connection is actually the BASEENTITY.LINKID field. The LINKID
    > matches IDs in the TRADE or INSTR table. Like this:
    >
    > BASEENTITY
    > ID=1, LINKID=100
    > ID=2, LINKID=200
    >
    > TRADE
    > ID=100
    >
    > INSTR
    > ID=200
    >
    > Hibernate cannot handle this. Unidirectional one to one relationships
    > require annotation on each end. The 'table per class' inheritance
    > model requires the ID fields in TRADE and INSTR to be foreign keys of
    > BASEENTITY, which they are not.
    >
    > Look forward to any advice.
    > Thanks,
    > John
    >
    >



    This archive was generated by hypermail 2.0.0 : Thu Apr 01 2010 - 12:27:18 EDT