I have a domain Object Customer:
I am using a HibernateCursorItemReader to select all the Customers who have not been processed.
private boolean processed;
private String name;
Then in my Writer, I loop through the batch of 100 customers calling this method for each one:
<bean id="customerReader" class="org.springframework.batch.item.database.HibernateCursorItemReader">
<property name="queryString" value="from Customer where processed = false" />
<property name="sessionFactory" ref="sessionFactory" />
<property name="fetchSize" value="100" />
<property name="useStatelessSession" value="true" />
<bean id="customerWriter" class="com.CustomerWriter"/>
<batch:job id="customerProcessJob" >
<batch:step id="customerProcessJob_step1" >
<batch:tasklet transaction-manager="transactionManager" >>
<batch:chunk reader="customerReader" writer="customerWriter" commit-interval="1">
This causes a deadlock, as the transaction on the updateCustomer method I think is conflicting with the transaction held open by the HibernateCursorItemReader?
@Transactional( propagation = Propagation.MANDATORY)
public void updateCustomer(Customer cust)
As a test I called another DAO method, that has no interaction with the CUSTOMER table, which causes no deadlock and everything continues to process.
Is this possible, to update an object whilst cursing through it? Or is it something fundamentally wrong with my set up?