Yes, I think you should look more carefully at the blog I gave :p. In fact, Gavin describes how to use a scrollable result.
I guess this is why you're obtaining an outofmem : list() tries to load everything in memory, not just the 1000 elements you want to process, so it makes far too much people for your RAM :-).
Quote:
Code:
Session session = sessionFactory.openSession();
Transaction tx = session.beginTransaction();
ScrollableResults customers = session.getNamedQuery("GetCustomers")
.scroll(ScrollMode.FORWARD_ONLY);
int count=0;
while ( customers.next() ) {
Customer customer = (Customer) customers.get(0);
customer.updateStuff(...);
if ( ++count % 20 == 0 ) {
//flush a batch of updates and release memory:
session.flush();
session.clear();
}
}
tx.commit();
session.close();
http://blog.hibernate.org/cgi-bin/blosx ... 004/08/26/