-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Getting sublist from huge List
PostPosted: Tue Sep 28, 2010 3:57 am 
Newbie

Joined: Tue Sep 28, 2010 3:20 am
Posts: 5
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" :-)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.