cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <>
Subject Re: SelectQuery with setPageSize
Date Mon, 01 Dec 2014 11:15:47 GMT

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: 


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.


> 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

View raw message