Results 1 to 3 of 3

Thread: Question about commit-interval and pageSize

  1. #1
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    18

    Default 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. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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?

  3. #3
    Join Date
    Mar 2009
    Location
    Germany
    Posts
    18

    Default

    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

Posting Permissions

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