Hi,
My application uses a collection of "Samples":
Code:
List<Samples> samples;
When a new samples comes in, i remove the oldes sample from the list
Code:
if (samples.size() == MAX)
samples.remove(0);
samples.add(newSample)
Clients retrieve a relative small subset of the list:
Code:
List<Samples> subset= samples.sublist(first,last);
My current implementation uses plain ArrayList.
I want to make the collection persistent using hibernate (i'm using JPA annotations).
My question is: as the collections can get huge, I never want to load this collection into memory, it will be slow and it is likely that it will not fit into memory. How do I have to use hibernate in order that it will never try to load the whole collection?
I still want to be able to control the maximum size of the number of samples in the database (using the "MAX" variable).
I read that defining the collection as "extra lazy", it will not load the collection into memory when samples.size() is called.
But how about the methods List.sublist(int first, int last) and List.remove(int index)? will they trigger the "loading of whole collection"?
I have a feeling that my approach will try to load the whole collection...
Please some help/advice (i'm a hibernate "beginner" :-)