Details
-
Idea
-
Resolution: Unresolved
-
Major
-
None
-
2.0 M4
-
None
-
Medium
-
Description
I suggest we add a method
com.xpn.xwiki.XWiki.saveDocuments(List<XWikiDocument>, XWikiContext) throws XWikiException
This method would save a list of documents in a single database transaction.
As I imagine it, setComment() and setMinorEdit() would be called on each document before sending them to saveDocuments.
Since (as far as I can tell) it's impossible to save documents in multiple databases with a single transaction, I think it ought to throw an exception if the user tries. It is draconian but in my opinion the user should be able to rely on it using a single transaction.
I haven't looked in to it very carefully, but it looks like a matter of calling:
store.beginTransaction(context);
try{
for(XWikiDocument doc : docs){
orig = doc.getOrigionalDocument();
store.saveXwikiDoc(doc,context,false); //bTransaction = false
(notification stuff)
}
store.endTransaction(context, true);
}finally{
store.endTransaction(context, false);
}
See http://markmail.org/message/7qtx7fnxxgxkpwcl for the started discussion