RESOLVED - issue BATCH-262: Hibernate Job blocks on flush

http://jira.springframework.org/browse/BATCH-262

The hibernate job blocks with high isolatio nlevels because it is reading a cursor and then updating the same objects (the cursor is in a different transaction because it uses openSession()).

The resolution is to change the isolation level - might be worth some more careful work later to encourage the right sort of best practice.
This commit is contained in:
dsyer
2007-12-22 09:40:59 +00:00
parent 376e84ff06
commit c022df6ce0
4 changed files with 50 additions and 30 deletions

View File

@@ -75,17 +75,22 @@ public abstract class AbstractCustomerCreditIncreaseTests extends AbstractValida
final List matches = new ArrayList();
jdbcTemplate.query(ALL_CUSTOMERS, new RowMapper() {
new TransactionTemplate(transactionManager).execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
jdbcTemplate.query(ALL_CUSTOMERS, new RowMapper() {
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
final BigDecimal creditBeforeUpdate = (BigDecimal) creditsBeforeUpdate.get(rowNum);
final BigDecimal expectedCredit = creditBeforeUpdate.add(CREDIT_INCREASE);
if (expectedCredit.equals(rs.getBigDecimal(CREDIT_COLUMN))) {
matches.add(rs.getBigDecimal(ID_COLUMN));
}
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
final BigDecimal creditBeforeUpdate = (BigDecimal) creditsBeforeUpdate.get(rowNum);
final BigDecimal expectedCredit = creditBeforeUpdate.add(CREDIT_INCREASE);
if (expectedCredit.equals(rs.getBigDecimal(CREDIT_COLUMN))) {
matches.add(rs.getBigDecimal(ID_COLUMN));
}
return null;
}
});
return null;
}
});
assertEquals(getExpectedMatches(), matches.size());