RESOLVED - BATCH-650: Use FORWARD_ONLY as scroll mode in HibernateCursorItemReader

added item buffer and made the cursor forward-only (+ had to fix samples using stateful items with rollback)
This commit is contained in:
robokaso
2008-06-04 13:43:00 +00:00
parent c21032332b
commit d377e4c5c3
7 changed files with 95 additions and 55 deletions

View File

@@ -52,8 +52,12 @@ public class CustomerCredit {
this.name = name;
}
public void increaseCreditBy(BigDecimal sum) {
this.credit = this.credit.add(sum);
public CustomerCredit increaseCreditBy(BigDecimal sum) {
CustomerCredit newCredit = new CustomerCredit();
newCredit.credit = this.credit.add(sum);
newCredit.name = this.name;
newCredit.id = this.id;
return newCredit;
}
public boolean equals(Object o) {

View File

@@ -45,8 +45,7 @@ public class BatchSqlCustomerCreditIncreaseWriter implements ItemWriter, Initial
* @see org.springframework.batch.item.processor.DelegatingItemWriter#doProcess(java.lang.Object)
*/
public void write(Object data) throws Exception {
CustomerCredit customerCredit = (CustomerCredit) data;
customerCredit.increaseCreditBy(FIXED_AMOUNT);
CustomerCredit customerCredit = ((CustomerCredit) data).increaseCreditBy(FIXED_AMOUNT);
delegate.write(customerCredit);
}

View File

@@ -29,8 +29,7 @@ public class CustomerCreditIncreaseWriter extends AbstractItemWriter {
* @see org.springframework.batch.item.processor.DelegatingItemWriter#doProcess(java.lang.Object)
*/
public void write(Object data) throws Exception {
CustomerCredit customerCredit = (CustomerCredit) data;
customerCredit.increaseCreditBy(FIXED_AMOUNT);
CustomerCredit customerCredit = ((CustomerCredit) data).increaseCreditBy(FIXED_AMOUNT);
customerCreditDao.writeCredit(customerCredit);
}