Announcement Announcement Module
No announcement yet.
JpaPagingItemReader skips records in process indicator pattern Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JpaPagingItemReader skips records in process indicator pattern

    I am curious if anyone has configured a JpaPagingItemReader (or HibernatePagingItemReader) in a process indicator pattern. I have a dedicated PROCESSED column which the the reader scans all values of 'N' and which the processor/writer updates and commits to 'Y':
    <bean id="jpaPagingItemReader"
    <property name="queryString"
    			value="from WorkTable w where w.processed='N'" />
    <property name="saveState" value="false" />
    <property name="pageSize" value="2" />
    Reading up on the forum, I find conflicting responses. The thread SpringBatch and Multithreading seems to suggest a PagingItemReader can be used in a process indicator pattern, as Dave states:
    By the way, you probably shouldn't use JpaItemReader in a multi-threded step unless you have a process indicator and set the saveState flag set to false
    However in another thread, Records omitted from query using JpaPagingItemReader, Dave writes:
    You can't modify the data that the reader is consuming while the step is still active. The most common pattern is to do the updates in another step or after the step in a listener.
    My current behavior is that of the second thread—where alternate pages are omitted from processing (on Spring Batch 2.1.9.RELEASE).

    Thanks in advance! Any ideas most appreciated ...

  • #2
    The question here is whether that flag is part of your item or not. If it is not, you should be able to use a ChunkListener to update the rows (via Jdbc...not JPA) as they are processed.


    • #3
      Thanks for the reply.

      The PROCESSED column is definitely one of the fields of the item's POJO. Thus, there should be a way to make it work without using a ChunkListener, correct?