Re: Random selection

From: Mike Kienenberger (mkienen..laska.net)
Date: Sat Dec 20 2003 - 09:55:57 EST

  • Next message: Jim Menard: "Re: Random selection"

    Jim Menard <jim..o.com> wrote:
    > I have an album of photos, and I want to select a random photo to
    > display. I figured I could use setFetchingDataRows, select the entire
    > list of photos, then randomly select one and call objectFromDataRow to
    > "flesh out" the photo.
    >
    > Cayenne normally performs magic to retrieve the list of photos. How do
    > I do it myself? Alternately, how can I tell the album to use
    > setFetchingDataRows when it selects the list of photos?
    >
    > Finally, is this an unnecessary optimization? Should I not worry about
    > reading all of the photos into memory and just call album.getPhotos()?

    Have you looked at using Paginated Queries instead?

    You could just set the page size to 1, and read in objects as regular
    DataObjects rather than DataRows.

    http://www.objectstyle.org/cayenne/userguide/perform/paged-queries.html



    This archive was generated by hypermail 2.0.0 : Sat Dec 20 2003 - 09:55:48 EST