title: IBM Case Manager: Intermittantly getting "Update sequence number mismatch" trying to save case
body: <p>I'm using the Java API with Case Manager 5.2.1, on Windows.</p>
  
  <p>My web service does the following:</p>
  
  <pre><code>// 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);
  </code></pre>
  
  <p>PROBLEM: I intermittently get this error:</p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>I <em>know</em> there are only two case.save() calls: one for "newPendingDocument", the other (much later) for "cs".</p>
  
  <p>I execute the <em>SAME</em> code multiple times: sometimes it works, sometimes if fails with the
  "Update sequence number mismatch" error.</p>
  
  <p>Q: Any ideas/any suggestions as to how I can troubleshoot this problem? </p>