I'm running into what appears to be a bug in how XObjects are removed and added, and wanted to ask if I am perhaps using them incorrectly.
Basically I am performing the following sequence of steps: 1. Insert some XObjects to an XWikiDocument using document.newXObject(). Save the document and reload. 2. Delete one of the XObjects in the middle of the list of XObjects, using document.removeXObject(). Save the document and reload. 3. Add another XObject using document.newXObject(). Save. Here is that the document's xObjects data looks like after each step (simplified for demonstration purposes): AFTER STEP 1: index=0 object="<?xml...>...<number>0</number>...</xml>" index=1 object="<?xml...>...<number>1</number>...</xml>" index=2 object="<?xml...>...<number>2</number>...</xml>" AFTER STEP 2 (assume I delete the xObject with index=1): index=0 object="<?xml...>...<number>0</number>...</xml>" index=1 object=null index=2 object="<?xml...>...<number>2</number>...</xml>" AFTER STEP 3: index=0 object="<?xml...>...<number>0</number>...</xml>" index=1 object=null index=2 object="<?xml...>...<number>2</number>...</xml>" index=3 object="<?xml...>...<number>2</number>...</xml>" As you can see there are two related problems here: 1. A null object is being preserved in the list of XObjects, even after being rehydrated from Hibernate following a server restart. 2. The index=3 object has been given a 'number' of '2' -- but that number is already in use by index=2 object. Because of this, saving the document actually fails: I am receiving a NonUniqueObjectException as follows: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.xpn.xwiki.objects.BaseObject#-1957000305211198111] Looking in the XWiki code it looks like this is essentially happening because the value of 'number' is computed as 'list size - 1'. So that 'null' that gets preserved in the list seems to be throwing off the logic. Am I using newXObject()/removeXObject() improperly? Please advise. Thanks! -- View this message in context: http://xwiki.475771.n2.nabble.com/Bug-in-XObjects-or-am-I-using-them-incorrectly-tp7603477.html Sent from the XWiki- Dev mailing list archive at Nabble.com.

