Failure to save a document with an object with updated (some removed) properties produced the following stack trace:
com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving document xwiki:<myDocumentReference>
...<my code stack>
Caused by: com.xpn.xwiki.XWikiException: Error number 3212 in 3: Exception while saving property instanceStateDetails of object <referenceToPageContainingObject>
... 12 common frames omitted
Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.xpn.xwiki.objects.StringProperty#<property><myPropertyName></myPropertyName></property>]
... 14 common frames omitted
The issue is that, after this exception and on first inspection, the UI was showing no problem, as if the save was successful. However, a second module that was performing a query on the DB was not seeing the previous document save, as hibernate failed to save it to the DB. Thus, it was the document cache (most likely) that was returning and displaying an updated document, even if the document save failed and the save itself was theoretically canceled (i.e. the entire save was reverted if one property save failed by throwing an exception abd bubbling it up).
In order to try to help reproduce this, what I did to end up with the exception was to call object.removeField(fieldname) in order to remove a property value from an object, instead of calling object.safeput(fieldname, propClass.newProperty()) (i.e. I was removing the value completely instead of setting an empty value). I had forgotten we had changed this behavior relatively recently (to always store properties, even if empty in the DB).