Guava also has a lot of handy classes for working on collections.

2011/8/18 Simone Tripodi <simonetrip...@apache.org>

> Salut Sébastien,
> wouldn't the List#subList(int, int)[1] method be helpful for your purposes?
> HTH,
> Simo
>
> [1]
> http://download.oracle.com/javase/1.5.0/docs/api/java/util/List.html#subList(int
> ,
> int)
>
>
> http://people.apache.org/~simonetripodi/
> http://www.99soft.org/
>
>
>
> On Thu, Aug 18, 2011 at 2:26 PM, Sébastien Lorber
> <lorber.sebast...@gmail.com> wrote:
> > Hello,
> >
> >
> > It's not the first time i have to split a big list of hibernate entities
> > ID's to sublists of 100 items for exemple so that i could load all these
> > entities 100 in a single request (with a "where id in (<id sublist>")
> >
> > Thus I want to iterate easily on sublists of a list, with the possibility
> to
> > give the sublist a size...
> > I though i would find the tool in apache collections but i didn't find
> it.
> > Perhaps i've missed the class...
> >
> >
> >
> > If there's no tool to do that yet, i think it would be great to make one
> in
> > apache collections.
> >
> > The kinda simple implementation i use at work is the following:
> > http://pastebin.com/CRitkWTG
> >
> >
> > And you use it like that:
> >
> >        // We load vehicles 100 by 100
> >         for ( List<String> idSublist : new
> > SublistIterable<String>(allIds,100) ) {
> >            List<Vehicle> vehiclesSublist =
> vehicleDAO.findByIds(idSublist);
> >            // blablabla
> >        }
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>
>


-- 
--
David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen

Reply via email to