Announcement Announcement Module
Collapse
No announcement yet.
Question about commit-interval and pageSize Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question about commit-interval and pageSize

    Hi,

    I'm trying to use a JpaPagingItemReader to read all records from a database that match a given criteria. What I don't understand is the relation between the parameters "commit-interval" in the tasklet and the "pageSize" in the ItemReader.

    When I set both parameters to "1", then everything works fine. But when I increase the value, then records are missing in the output.

    Example: I have 10 records in the DB and set both parameters to 3. Then 9 records are written corrently, but the 10th is mising.

    The configuration is as follows:

    Code:
    <batch:job id="apolloRequestDispatchJob">
        <batch:step id="readNewRequests">
            <batch:tasklet>
                <batch:chunk reader="apolloRequestReader"
                    processor="apolloRequestProcessor" 
                    writer="apolloRequestWriter"
                    commit-interval="3" />
            </batch:tasklet>
        </batch:step>
    </batch:job>
    
    <bean id="apolloRequestReader" class="org.springframework.batch.item.database.JpaPagingItemReader">
        <property name="entityManagerFactory" ref="entityManagerFactory" />
        <property name="pageSize" value="3" />
        <property name="queryString"
    	value="select r from ApMbsRequest r order by r.mbRequestId asc" />
    </bean>
    (The parameter value "3" is just an example, normally I would increase the value.)

    What am I doing wrong? I'd appreciate any hints!

    Cheers,
    Stephan

  • #2
    I can't see what the problem is, and there is no connection between commit interval and page size. It all works fine for me. Can you provide a test case?

    Comment


    • #3
      Hi,

      sorry for getting back to you so late.

      I think now I found out what the problem was. It wasn't the transaction configuration or commit interval. I use a JpaPagingItemReader and did not notice that the read items were not managed by the EntityManager. So changes to the items did not have any effect to the database. Now I added a call to entityManager.merge() and it seems to work fine.

      Cheers,
      Stephan

      Comment

      Working...
      X