RE: ordering and path expression

From: Gentry, Michael \(Contractor\) ("Gentry,)
Date: Wed Aug 31 2005 - 11:05:08 EDT

  • Next message: Mike Kienenberger: "Re: Simple query Expression question"

    Ah, the orderings only apply to the returned object(s). In your case,
    you are asking for a Patient with an ID of 1234. Only one object is
    coming back in your List. Your studies will be prefecthed, but will be
    in "random" order (to the best of my knowledge).

    The easiest way to handle this is to add a cover method in your subclass
    (the non-underscore Patient.java) to do an in-memory sort of the studies
    and use that method to get them in the order you want.

    Look at
    http://www.objectstyle.org/cayenne/userguide/fetch/orderings.html to see
    how to do the in-memory sort.

    /dev/mrg

    -----Original Message-----
    From: Arnaud Garcia [mailto:arnaud.garci..im.hcuge.ch]
    Sent: Wednesday, August 31, 2005 10:10 AM
    To: cayenne-use..bjectstyle.org
    Subject: ordering and path expression

    Hi,

    I would like to know how to use the ordering function with path
    expression in my queries.
    My objects are "Patient.class" with a list of "study.class" objects wich

    has a studydate getter (a simple one to many relationship)

    I want to retrieve my patients (by ID) with all the studies ordering by
    date (the date is a filed of Study.class),

    My code:
             Expression exp = ExpressionFactory.matchExp(patientid, "1234");
            query = new SelectQuery(Patient.class, exp);
            query.addPrefetch(studies);
            query.addOrdering(".....???...", true); // maybe something
    like: toPatient.study.studydate
            List patients = context.performQuery(query);

    many thanks for help

    arnaud



    This archive was generated by hypermail 2.0.0 : Wed Aug 31 2005 - 11:05:12 EDT