FAQ
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.

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.

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

Search Discussions

  • Andrus Adamchik at Aug 3, 2008 at 2:57 pm

    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
  • Aristedes Maniatis at Aug 3, 2008 at 3:11 pm

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

    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)?
    I've got them in my queue to commit and will do so in the next few
    days. I've spoken to Marcin about which bits need cleaning up already.

    Ari



    -------------------------->
    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
  • Andrus Adamchik at Aug 3, 2008 at 3:19 pm
    Cool. Yeah, I just noticed that the Jira is assigned to you.

    Andrus
    On Aug 3, 2008, at 11:10 AM, Aristedes Maniatis wrote:

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

    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)?
    I've got them in my queue to commit and will do so in the next few
    days. I've spoken to Marcin about which bits need cleaning up already.

    Ari



    -------------------------->
    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

  • Marcin Skladaniec at Aug 5, 2008 at 1:39 pm
    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
  • Aristedes Maniatis at Aug 5, 2008 at 1:46 pm

    On 05/08/2008, at 11:35 PM, Marcin Skladaniec wrote:

    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.
    I'll have a bit of a chat to Marcin about this on the phone and get
    him up to speed where this was left off.... I've got some
    documentation to show him before we need to bring this back on the list.

    Ari



    -------------------------->
    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
  • Andrus Adamchik at Aug 5, 2008 at 2:10 pm
    Cool. I also think we need a separate Jira for vertical inheritance.
    Many implementation steps may overlap with horizontal, but this would
    be good for the RELEASE-NOTES and overall clarity.

    Andrus
    On Aug 5, 2008, at 9:45 AM, Aristedes Maniatis wrote:

    On 05/08/2008, at 11:35 PM, Marcin Skladaniec wrote:

    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.
    I'll have a bit of a chat to Marcin about this on the phone and get
    him up to speed where this was left off.... I've got some
    documentation to show him before we need to bring this back on the
    list.

    Ari



    -------------------------->
    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

  • Lachlan Deck at Aug 6, 2008 at 1:31 am

    On 06/08/2008, at 12:09 AM, Andrus Adamchik wrote:

    Cool. I also think we need a separate Jira for vertical inheritance.
    Many implementation steps may overlap with horizontal, but this
    would be good for the RELEASE-NOTES and overall clarity.
    Let me know too what from last years discussion what concepts/ideas
    needed further clarification.
    On Aug 5, 2008, at 9:45 AM, Aristedes Maniatis wrote:

    On 05/08/2008, at 11:35 PM, Marcin Skladaniec wrote:

    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.
    I'll have a bit of a chat to Marcin about this on the phone and get
    him up to speed where this was left off.... I've got some
    documentation to show him before we need to bring this back on the
    list.
    with regards,
    --

    Lachlan Deck
  • Andrus Adamchik at Aug 5, 2008 at 2:07 pm

    On Aug 5, 2008, at 9:35 AM, Marcin Skladaniec wrote:

    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-795says
    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.
    I guess CAY-795 is just not specific enough. It says "horizontal" in
    the title, but the steps to implement it are described in a rather
    generic fashion. Not sure if we have a separate Jira for vertical?
    Maybe Ari can open a new Jira on that.

    Thanks,
    Andrus

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categoriescayenne
postedAug 3, '08 at 1:20a
activeAug 6, '08 at 1:31a
posts9
users4
websitecayenne.apache.org

People

Translate

site design / logo © 2022 Grokbase