Description
The error is
Wrapped Exception: a different object with the same identifier value was already associated with the session: [com.xpn.xwiki.doc.XWikiDocument#104408758] at com.xpn.xwiki.store.XWikiHibernateStore.loadXWikiDoc(XWikiHibernateStore.java:849) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.store.XWikiCacheStore.loadXWikiDoc(XWikiCacheStore.java:296) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.XWiki.getDocument(XWiki.java:1472) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.XWiki.getDocument(XWiki.java:1515) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.XWiki.getXWikiPreference(XWiki.java:2252) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.XWiki.hasBacklinks(XWiki.java:6210) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:678) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:183) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.store.XWikiHibernateAttachmentStore.deleteXWikiAttachment(XWikiHibernateAttachmentStore.java:279) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.store.XWikiHibernateAttachmentStore.deleteXWikiAttachment(XWikiHibernateAttachmentStore.java:215) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.doc.XWikiDocument.deleteAttachment(XWikiDocument.java:4500) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.doc.XWikiDocument.deleteAttachment(XWikiDocument.java:4480) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na] at com.xpn.xwiki.web.DeleteAttachmentAction.action(DeleteAttachmentAction.java:127) [xwiki-platform-oldcore-3.2-20110802.181227-125.jar:na]
What happens is that deleteXWikiAttachment() saves the document and while doing so it checks if there are backlinks. This check is done by looking at XWikiPreferences. Thus if it's not in the document cache Hibernate will try to load it and fail since it's in a session that already has it in memory.
The use case for this is when trying to delete an attachment from the Admin Import screen.