Results 1 to 3 of 3

Thread: JpaPagingItemReader skips records in process indicator pattern

  1. #1
    Join Date
    Feb 2013
    Posts
    2

    Default 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':
    Code:
    <bean id="jpaPagingItemReader"
    		class="org.springframework.batch.item.database.JpaPagingItemReader">
    <property name="queryString"
    			value="from WorkTable w where w.processed='N'" />
    <property name="saveState" value="false" />
    <property name="pageSize" value="2" />
    ...
    </bean>
    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. #2
    Join Date
    Sep 2008
    Location
    Chicagoland, IL
    Posts
    350

    Default

    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.
    Michael Minella
    Spring Batch Lead
    Author - Pro Spring Batch
    http://www.michaelminella.com
    Twitter: @MichaelMinella

  3. #3
    Join Date
    Feb 2013
    Posts
    2

    Default

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •