[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Lazying-loading and Collection.size()
|
In other words, it will retrieve the entire resultset and dump it into
memory? Is there a way to perform the following operations efficiently?
1) get the size of the collection
2) retrieve an element at index X
all of this without retrieving the entire collection from the database and
(ideally) without issuing queries explicitly.
Gili
James Sutherland wrote:
>
> size() will instantiate lazy collections in EclipseLink and any other JPA
> implementation that I know of. I'm not sure the JPA spec says anything
> about it.
>
>
>
> cowwoc wrote:
>>
>> Hi,
>>
>> What does the JPA standard (and alternatively EclipseLink) say about Lazy
>> Loading and Collection/Set/List.size()? If the collection hasn't been
>> initialized yet, does size() simply invoke a count(*) query or does it
>> retrieve the entire collection including its elements?
>>
>> I'm thinking of the following use-case:
>>
>> 1) int size = myList.size();
>> 2) Object randomElement = myList.get((int) (Math.random() * size));
>>
>> What is guaranteed to happen under the hood according to JPA and
>> according to EclipseLink? Ideally I want to pass a Collection around my
>> API, instead of forcing it to be Query-aware and issue SQL statements
>> explicitly.
>>
>> Thank you,
>> Gili
>>
>
>
--
View this message in context: http://www.nabble.com/Lazying-loading-and-Collection.size%28%29-tp19581000p19608774.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.