OPEN - issue BATCH-364: StepScope responsibilities can be assumed by Step (not ApplicationContext)

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

Extend columns in attrs table -to avoid crashes resulting in optimistic lock failure.
This commit is contained in:
dsyer
2008-02-15 14:40:33 +00:00
parent 0fc3ec4cfc
commit 7096c8c024
19 changed files with 65 additions and 46 deletions

View File

@@ -45,6 +45,6 @@ public interface Chunker {
*
* @param stepExecution
*/
public void flush(StepExecution stepExecution);
public void flush(Entity stepExecution);
}

View File

@@ -75,6 +75,17 @@ public class Entity implements Serializable {
}
}
/**
*
*/
protected void decrementVersion() {
if (version == null || version.intValue()==0) {
version = new Integer(0);
} else {
version = new Integer(version.intValue() - 1);
}
}
// @Override
public String toString() {
return ClassUtils.getShortName(getClass()) + ": id=" + getId();
@@ -121,4 +132,5 @@ public class Entity implements Serializable {
}
return 39 + 87 * id.hashCode();
}
}

View File

@@ -357,6 +357,7 @@ public class StepExecution extends Entity {
*/
public synchronized void rollback() {
rollbackCount++;
decrementVersion();
}
/**

View File

@@ -210,28 +210,28 @@ public class StepExecutionTests extends TestCase {
}
public void testEqualsWithSameIdentifier() throws Exception {
StepExecution step1 = newStepExecution(new Long(100), new Long(11));
StepExecution step2 = newStepExecution(new Long(100), new Long(11));
Entity step1 = newStepExecution(new Long(100), new Long(11));
Entity step2 = newStepExecution(new Long(100), new Long(11));
assertEquals(step1, step2);
}
public void testEqualsWithNull() throws Exception {
StepExecution step = newStepExecution(new Long(100), new Long(11));
Entity step = newStepExecution(new Long(100), new Long(11));
assertFalse(step.equals(null));
}
public void testEqualsWithNullIdentifiers() throws Exception {
StepExecution step = newStepExecution(new Long(100), new Long(11));
Entity step = newStepExecution(new Long(100), new Long(11));
assertFalse(step.equals(new StepExecution()));
}
public void testEqualsWithNullJob() throws Exception {
StepExecution step = newStepExecution(null, new Long(11));
Entity step = newStepExecution(null, new Long(11));
assertFalse(step.equals(new StepExecution()));
}
public void testEqualsWithNullStep() throws Exception {
StepExecution step = newStepExecution(new Long(11), null);
Entity step = newStepExecution(new Long(11), null);
assertFalse(step.equals(new StepExecution()));
}
@@ -240,7 +240,7 @@ public class StepExecutionTests extends TestCase {
}
public void testEqualsWithDifferent() throws Exception {
StepExecution step = newStepExecution(new Long(43), new Long(13));
Entity step = newStepExecution(new Long(43), new Long(13));
assertFalse(execution.equals(step));
}