IBM Case Manager: Intermittantly getting "Update sequence number mismatch" trying to save case

2.4k views Asked by At

I'm using the Java API with Case Manager 5.2.1, on Windows.

My web service does the following:

// Create a brand new case
CaseType myCaseType = CaseType.fetchInstance(osRef, myCaseTypeName);
Case newPendingCase = Case.createPendingInstance(myCaseType);

// Save it now to get access to the Case ID
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
newCaseIdentifier = newPendingCase.getIdentifier();

// Fetch a fresh copy of the case instance
Case cs = Case.fetchInstanceFromIdentifier(osRef, newCaseIdentifier);

// Now set a whole bunch of properties, add documents, etc. etc.
...

// Finally, save all our updates: to "cs", not "newCaseIdentifier"
cs.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);

PROBLEM: I intermittently get this error:

The object {52EECAC2-38B2-4CB5-8F22-BAF33D6C35EC} of class "MyCaseTypeName" was not changed or deleted because it was modified one or more times in the repository since the application retrieved it. Update sequence number mismatch; requested USN = 0, database USN = 1

I know there are only two case.save() calls: one for "newPendingDocument", the other (much later) for "cs".

I execute the SAME code multiple times: sometimes it works, sometimes if fails with the "Update sequence number mismatch" error.

Q: Any ideas/any suggestions as to how I can troubleshoot this problem?

1

There are 1 answers

5
Christopher Powell On

Looking at the code that you provide I am confused as to why you would create a second Case instance. I would imagine that you would be better off doing this instead:

// Create a brand new case
CaseType myCaseType = CaseType.fetchInstance(osRef, myCaseTypeName);
Case newPendingCase = Case.createPendingInstance(myCaseType);

// Save it now to get access to the Case ID
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);
newCaseIdentifier = newPendingCase.getIdentifier();

// Fetch a fresh copy of the case instance (not sure if this is necessary)
newPendingCase = Case.fetchInstanceFromIdentifier(osRef, newCaseIdentifier);

// Now set a whole bunch of properties, add documents, etc. etc.
...

// Finally, save all our updates: to "newPendingCase"
newPendingCase.save(RefreshMode.REFRESH, null, ModificationIntent.MODIFY);

I haven't worked with Case Manager, but have worked with P8. The api calls are very similar.

The USN number can be a little tricky. If there is any time period that you are waiting for an external call (to a 3rd party REST interface for instance) you might want to do a newPendingCase.Refresh() after the call, and then repopulate any needed properties of the case.