Re: orderby on tomany relation

From: Jürgen Saar (jsaa..eb.de)
Date: Mon Mar 21 2005 - 06:15:58 EST

  • Next message: tnaki..ofthome.net: "select distinct"

    I agree to this ... it would be a great help for me
    to get the relation-data sorted from database.

    Keep the data sorted on inserts to the relation
    would be fine, but not mandatory.

    Now I have to manage the orderby-information
    in addition to the cayenne-repository and overide
    the readProperty for relations and generate my
    own SelectQuery for reading the Relation-Data

    cayenne-use..bjectstyle.org schrieb am 18.03.05 18:43:30:
    >
    > Hi Holger,
    >
    > What I disagree with (and disagreed in the past) is that a difficulty with
    > a 100% solution should prevent us from releasing a partial, but still very
    > useful sorting of relationships during fetch.
    >
    > Ordering is mainly used for display purposes and many of the cases are
    > read-only. So it will be helpful right away to a lot of users. As we go we
    > can improve it, e.g. adding ordering refresh hook on commit.
    >
    > Andrus
    >
    >
    > > Jürgen Saar wrote:
    > >> is there a way to define a default ordering
    > >> for a relation?
    > >
    > > As Andrus wrote this feature is often required (last week, IIRC?) and -
    > > when 'done right' can save a lot of manual coding, not to mention the
    > > possibilities for inconsistencies, model/view mish-mash etc.
    > > Unfortunately the problem is not really difficult, but simply affects
    > > many different parts of Cayenne:
    > >
    > > - it is not enough to order the relationship array after fetching; you
    > > really, really want to keep this list ordered even when you're
    > > adding/removing objects. Long ago I wrote a SortedList implementation
    > > exactly for this purpose (which was quite difficult since the
    > > List/Collections contracts are sloppy and partially contradictory) and
    > > contributed it to Cayenne but since I didn't keep up with development I
    > > don't know where this currently floats around. Send me an email if you
    > > need it. Right now I'm not even using Cayenne. :(
    > >
    > > - writing additional cover methods that do the required ordering kind of
    > > works, but is IMHO really just a band-aid and sooner or later will
    > > create unpleasant inconsistencies. You _will_ forget to call the manual
    > > sorting somewhere.
    > >
    > > - such a feature is not really useful without Modeler support. Ideally
    > > you would select either an ObjEntity or a relationship, check an
    > > "ordered" checkbox and set up a list of orderings by attribute (e.g.
    > > ascending by name, descending by rank etc.). Simply slapping Comparable
    > > onto the ObjEntity class is not helpful since you still need to generate
    > > the ORDER BY statements mapped to the correspondig DbAttributes;
    > > otherwise you wouldn't get any server-side sorting, which was the whole
    > > point of the idea. ;-)
    > > The Modeler-generated orderings would still be available (and required
    > > for insertions/removals) on the object level via an automatically
    > > generated Comparator and addition of Comparable to the generated class.
    > >
    > > One really should not have to write any application code for this.
    > >
    > > Holger

    ______________________________________________________________
    Verschicken Sie romantische, coole und witzige Bilder per SMS!
    Jetzt bei WEB.DE FreeMail: http://f.web.de/?mc=021193



    This archive was generated by hypermail 2.0.0 : Mon Mar 21 2005 - 06:16:08 EST