I am writing a batch and using JPA for persistence. I have a table with a lot of records and I need to read all the records by groups of 100 or 500. I don't want to load all the records into memory at once, because there won't be enough memory.
For example:
- First group: records 1 to 500
- Second group: records 501 to 1000
- etc
Is there a better way to do it?
Related questions
JPA: what is the proper pattern for iterating over large result sets?