xedo
xedo

Reputation: 1147

JdbcPagingItemReader endless loop

Why is it getting a endless loop? always return the ten records and doesn't continue with the next ones

<bean id="pagingItemReader1" class="org.springframework.batch.item.database.JdbcPagingItemReader" scope="step">
    <property name="dataSource" ref="dataSource1" />
    <property name="queryProvider">
        <bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
            <property name="dataSource" ref="dataSource1" />
            <property name="selectClause" value="select id, image" />
            <property name="fromClause" value="from squares" />
            <property name="whereClause" value="where image like :value1 or image like :value2" />
            <property name="sortKey" value="id" />
        </bean>
    </property>
    <property name="parameterValues">
        <map>
            <entry key="value1" value="%/images/%" />
            <entry key="value2" value="%/temp/%" />
        </map>
    </property>
    <property name="pageSize" value="10" />
    <property name="rowMapper">
        <bean class="test.batch.ImagesRowMapper" />
    </property>
</bean>

Using MySQL 5.1

Upvotes: 1

Views: 698

Answers (2)

double_g
double_g

Reputation: 836

Parentheses are missing.

Please change
"whereClause" value="where image like :value1 or image like :value2"

to
"whereClause" value="where (image like :value1 or image like :value2)"

Upvotes: 1

double_g
double_g

Reputation: 836

I don't know why but I can share my solution with you.

Increase your pageSize over the total number of rows (of the current query of course).

This appears when I am using a 'OR' in whereClause

Someone can investigate ?

Upvotes: 0

Related Questions