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?