Re: Insert at a particular position in the detail list

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Fri Sep 26 2008 - 15:52:05 EDT

  • Next message: Scott Anderson: "RE: Insert at a particular position in the detail list"

    That's a good point - we are trying to bridge the gap between OO and
    RDB worlds in a best possible way. And I wish we could do a reasonable
    ordering implementation (and without a join table). Otherwise the
    java.util.List "contract" is indeed broken.

    Andrus

    On Sep 26, 2008, at 10:39 PM, Robert Zeigler wrote:

    > I disagree. By the "intrinsic attribute" argument, we wouldn't be
    > trying to support inheritance and other useful features.
    > The point of ORM is to bridge the gap that exists between Object
    > Models and Relational Models. The fact is that, in java, at least,
    > java.util.List is ordering-aware: you expect items that go into the
    > list to come back out in the same order. So supporting the notion
    > of an ordered collection of items, particularly when the
    > relationship is mapped as a List,
    > is probably "the right thing" to do.
    >
    > In fact, ordering /is/ an intrinsic database /operation/ on a
    > relationship, although not an intrinsic /attribute/. But it happens
    > often enough that you /do/ care about the ordering of the
    > relationship that it would be awfully nice to /not/ have to override
    > the getter/setter to provide sorting. This is, of course, how I've
    > done things in the past... and wished cayenne had built-in support
    > for ordered collections. Having the sorting occur in the getter is
    > inefficient; unless you take great pains to ensure that you don't re-
    > sort unless absolutely necessary, then every fetch of your list is
    > an o(n) operation, instead of just the first operation (which will
    > load the values, or at least the keys, from the db) being an O(n)
    > operation. If we shifted the burden of managing ordered
    > relationships to cayenne, then cayenne can handle the complexity of
    > determining when a collection has been modified/needs to be
    > resorted, vs. when it doesn't, and we can minimize the effect of
    > having ordered collections.
    >
    > Finally, Hibernate and other ORM tools support this feature; I'm not
    > saying we should implement every feature of other ORMS; cayenne has
    > its set of strengths that appeal to the people who use it, and some
    > "features" of other ORMS are just a pain. But I think this is one
    > case where supporting a feature supported by all of the major ORM
    > players would make Cayenne more competitive.
    >
    > So, from the "theoretical" perspective (what does an ORM do), from a
    > pragrmatic perspective (nice to offload and reuse the burden of
    > efficient sorted relationship management), and the "competition"
    > perspective, we really ought to support sorted lists.
    >
    > Robert
    >
    > On Sep 26, 2008, at 9/261:47 PM , Scott Anderson wrote:
    >
    >> Cayenne is there to abstract the interface to the tools that the
    >> database provides, not to obfuscate the tools. Custom ordering is
    >> not an
    >> intrinsic attribute of a relationship in the database; it should
    >> not be
    >> an intrinsic attribute of a relationship in Java.
    >>
    >> If you need to sort the results or a JOIN, override the getter. If
    >> you
    >> need to maintain custom ordering, model a linked list in your schema.
    >> This just isn't Cayenne's responsibility.
    >
    >



    This archive was generated by hypermail 2.0.0 : Fri Sep 26 2008 - 15:52:36 EDT