Re: [CONF] Apache Cayenne Documentation: Inheritance overview (page created)

From: Craig L Russell (Craig.Russel..un.COM)
Date: Sun Jun 03 2007 - 07:44:47 EDT

  • Next message: Andrus Adamchik: "Re: [CONF] Apache Cayenne Documentation: Inheritance overview (page created)"

    Hi Andrus,

    On Jun 3, 2007, at 1:50 AM, Andrus Adamchik wrote:

    > On Jun 3, 2007, at 2:00 AM, Craig L Russell wrote:
    >> I hope this doesn't confuse things more, but in reality, you often
    >> have schema that fall into multiple categories of mapping.
    > No confusion at all - in reality we do have to deal with mixed
    > scenarios, so we have to account for them.
    >> For example, a hierarchy might have a table that maps all of the
    >> fields of the superclass A. Class B extends A and has a table BS
    >> containing a discriminator column WHICHB and the fields of all of
    >> the subclasses of B. Another class C extends A and its table C
    >> maps only the fields of class C while subclasses C1 and C2 each
    >> have their own table for their fields.
    >> To make it easier on the ORM, table A might also include a
    >> discriminator column WHICHA that explicitly identifies the class
    >> that the row corresponds to.
    > One note - in Cayenne discriminator column is implemented via a
    > more generic entity qualifier expression (e.g. it can match
    > multiple columns or use some custom comparison condition). This
    > approach generally prevents a simplification of a mandatory
    > discriminator column on a root class, although we may actually work
    > around it and start by implementing a simplified case (i.e. support
    > entity qualifiers in the form "attribute = constant" on all
    > subentities).

    I've also implemented the entity qualifier expression, and you are
    right; it's much more generic. However, it's also nice for ease of
    use for the user to simply tell you that there is a discriminator
    column and specify the values for each subclass.
    > I am still entertaining the idea that we can support vertical
    > inheritance without a designator column, and I don't think that
    > having such column in place is such a big shortcut in
    > implementation. After all the logic will be the same as with
    > horizontal inheritance - sublcass criteria is an existence of a row
    > in the subclass table).

    The big win here is in performance. If you don't need the subclass
    values but need to know the subclass, then the discriminator allows
    you to instantiate the right class without a join.

    > Andrus

    Craig Russell
    Architect, Sun Java Enterprise System
    408 276-5638
    P.S. A good JDO? O, Gasp!

    This archive was generated by hypermail 2.0.0 : Sun Jun 03 2007 - 07:45:10 EDT