Re: model enhancements for inheritance

From: Marcin Skladaniec (marci..sh.com.au)
Date: Tue Aug 05 2008 - 09:35:26 EDT

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

    On 04/08/2008, at 12:56 AM, Andrus Adamchik wrote:

    >
    > 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)?
    Ari is taking care of this, sorry that I did so many files. i did not
    know I could use the same file name to override the old ones.

    >
    >
    >
    >> 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.
    >
    I'm now confused with vertical-horizontal naming. You say vertical,
    jira https://issues.apache.org/cayenne/browse/CAY-795 says horizontal.
    I guess we talk about the same thing anyway, but just to be sure: I'm
    trying to model a database schema where there are 3 tables: Artwork,
    Painting and Sculpture.
    Artwork is an abstract entity with its own table
    Painting and Sculpture are extending Artwork, but have their own
    tables as well.
    You are suggesting that both superclass and subclass should have PK,
    this means yet another table in required to link the two tables. This
    seems odd to me as the relationship is simple 1..1, is that a
    requirement of JPA ?
    I'm reading up on JPA, but I cannot find it.

    Best wishes
    Marcin




    This archive was generated by hypermail 2.0.0 : Tue Aug 05 2008 - 09:39:14 EDT