Re: model enhancements for inheritance

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Sun Aug 03 2008 - 10:56:31 EDT

  • Next message: Aristedes Maniatis: "Re: model enhancements for inheritance"

    On Aug 2, 2008, at 9:16 PM, Marcin Skladaniec wrote:

    > Hi
    >
    > I'm going to add support for horizontal inheritance to cayenne. I've
    > already added functionality for an entity to be abstract (https://issues.apache.org/cayenne/browse/CAY-794
    > ), now the second part.

    BTW, I don't recall those patches being committed. Which patches out
    of the 3 files there should go in? Is it just the latest one (abstract-
    obj-entity.diff)?

    > Current implementation of inheritance allows only one of two
    > parameters set: "inheritance" or "table/view"
    > If inheritance is selected the ObjEntity does not have any own
    > DbEntity or DbAttributes, it gets them only from the parent
    > ObjEntity. (although it has all the ObjAttributes defined in model)
    > Table/view is a simple approach where the ObjEntity gets its
    > attributes from its definition in model, there is no parent ObjEntity.

    Correct.

    > For horizontal inheritance ObjEnity.getAttributes() should return
    > both the attributes defined in model as well as from parent ObjEntity.
    > Yet having both parameters accepted at the same time might now do it
    > well enough, therefore I would like to propose adding yet another
    > parameter to the model: "inheritance db relationship". On database
    > level the horizontal inheritance is nothing more than a one-to-one
    > relationship between two tables, and reflecting this in the model
    > will be required to route the queries and inserts correctly.
    >
    > Did I miss something ? Is that the right approach ?
    > Marcin

    I think you are talking about VERTICAL inheritance, not horizontal
    here. In case of horizontal you wouldn't have a relationship between
    subclass/superclass tables. Anyways, assuming we are discussing
    vertical inheritance, yes, there is a relationship involved. Per JPA
    approach, this relationship can be figured automatically : it is a
    1..1 relationship between the PK's of two tables. So we don't have to
    store it in XML, as we can find it in runtime. Still internally there
    should be a concept of a relationship joining parent and child tables,
    so you are right about the big picture.

    Andrus



    This archive was generated by hypermail 2.0.0 : Sun Aug 03 2008 - 10:57:08 EDT