Spring batch jpaPagingItemReader why some rows are not read?

后端 未结 4 467
Happy的楠姐
Happy的楠姐 2020-12-03 05:46

I \'m using Spring Batch(3.0.1.RELEASE) / JPA and an HSQLBD server database. I need to browse an entire table (using paging) and update items (one by one). So I used a jpaP

4条回答
  •  情书的邮戳
    2020-12-03 06:25

    I faced the same case, my reader was a JpaPagingItemReader that queried on a field that was updated in the writer. Consequently skipping half of the items that needed to be updated, due to the page window progressing while the items already read were not in the reader scope anymore.

    The simplest workaround for me was to override getPage method on the JpaPagingItemReader to always return the first page.

    JpaPagingItemReader jpaPagingItemReader = new JpaPagingItemReader() {
        @Override
        public int getPage() {
            return 0;
        }
    };
    

提交回复
热议问题