FAQ
Hi

I have a SelectQuery with setPageSize. After running this query i would
like to know on which index is specific object in this list, without
fetching full list of objects into memory. Is it possible to do it using
Cayenne API ?

Thanks
Arek

Search Discussions

  • Andrus Adamchik at Dec 1, 2014 at 11:18 am
    Hi,

    List.indexOf(..) is a linear search (unless the list is known to be ordered and you can use binary search). So on average such lookup would resolve ~50% of the objects.

    Another way is to query for this object directly against the DB. Yet another is to do an in-memory check of the object against the original SelectQuery qualifier:

        query.getQualifier().match(object);

    Neither of the 2 will always be equivalent to List.indexOf(..). After all DB data changes over time, and also SQL and in-memory eval have subtle differences. So make a decision based on the task at hand.

    Andrus

    On Dec 1, 2014, at 1:05 PM, Aradiusz Milewski wrote:

    Hi

    I have a SelectQuery with setPageSize. After running this query i would like to know on which index is specific object in this list, without fetching full list of objects into memory. Is it possible to do it using Cayenne API ?

    Thanks
    Arek

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriescayenne
postedDec 1, '14 at 10:08a
activeDec 1, '14 at 11:18a
posts2
users2
websitecayenne.apache.org

People

Translate

site design / logo © 2021 Grokbase