问题
I am using the JpaPagingItemReader in a Batch that modifies the data underlying the Readers query. The writer sets a Status to COMPLETED and then moves on processing the next chunk.
The outcome is that rows are omitted. When you have 100 rows to process and a chunk (and Reader size) of 10, the Reader reads 10 rows and processes them. With the second read he then tries to read Page 2 of the data but in my case uses a query that also questions the Status in it's where-clause. So the amount of records has decreased to 90 meanwhile. The Reader for Page 2 will now read the rows 11-20 from that result list and skip the first 10.
As there is no other Reader for JPA my question is - if it is possible to manipulate the Reader class to always deliver the first 10 rows. No Offset please! For example to manipulate the current page of the item Reader in the processor or writer. Or a different way to work around this.
We cannot use a Cursor item Reader by the way as it keeps the Cursor open which leads to locking situations in an older legacy DB2 database we must read data from.
来源:https://stackoverflow.com/questions/46320657/spring-batch-jpapagingitemreader-read-only-first-results