From 526941ba5e75a461b1b9277816b69b0f054ac020 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Wed, 4 Oct 2017 10:15:40 +0200
Subject: [PATCH] OO-3058: disable the optimistic locking by efficiency
 statement and replace with last commit win (in all case, the last which
 compute it win, locking or not)

---
 .../assessment/model/UserEfficiencyStatementImpl.hbm.xml    | 6 +++---
 src/main/java/org/olat/course/editor/PublishProcess.java    | 4 ++++
 .../java/org/olat/course/nodes/CheckListCourseNode.java     | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml b/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml
index d17e726464a..e706cd210f5 100644
--- a/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml
+++ b/src/main/java/org/olat/course/assessment/model/UserEfficiencyStatementImpl.hbm.xml
@@ -17,7 +17,7 @@
 		</generator>
 	</id>
 
-	<version name="version" access="field" column="version" type="int"/>
+	<property name="version" access="field" column="version" type="int"/>
 	<property name="creationDate" column="creationdate" type="timestamp" />
 	<property name="lastModified" column="lastmodified" type="timestamp" />
 
@@ -63,7 +63,7 @@
 		</generator>
 	</id>
 
-	<version name="version" access="field" column="version" type="int"/>
+	<property name="version" access="field" column="version" type="int"/>
 	<property name="creationDate" column="creationdate" type="timestamp" />
 	<property name="lastModified" column="lastmodified" type="timestamp" />
 
@@ -101,7 +101,7 @@
 		</generator>
 	</id>
 
-	<version name="version" access="field" column="version" type="int"/>
+	<property name="version" access="field" column="version" type="int"/>
 	<property name="creationDate" column="creationdate" type="timestamp" />
 	<property name="lastModified" column="lastmodified" type="timestamp" />
 
diff --git a/src/main/java/org/olat/course/editor/PublishProcess.java b/src/main/java/org/olat/course/editor/PublishProcess.java
index 8ff9a2a8070..5c1ab51e424 100644
--- a/src/main/java/org/olat/course/editor/PublishProcess.java
+++ b/src/main/java/org/olat/course/editor/PublishProcess.java
@@ -39,6 +39,7 @@ import java.util.zip.ZipOutputStream;
 import org.apache.poi.util.IOUtils;
 import org.olat.basesecurity.BaseSecurityManager;
 import org.olat.core.CoreSpringFactory;
+import org.olat.core.commons.persistence.DBFactory;
 import org.olat.core.gui.translator.Translator;
 import org.olat.core.id.Identity;
 import org.olat.core.id.OLATResourceable;
@@ -504,6 +505,9 @@ public class PublishProcess {
 			}
 		}
 		
+		//commit all changes before sending an event
+		DBFactory.getInstance().commitAndCloseSession();
+		
 		/*
 		 * broadcast event
 		 */
diff --git a/src/main/java/org/olat/course/nodes/CheckListCourseNode.java b/src/main/java/org/olat/course/nodes/CheckListCourseNode.java
index 1b9dfde7da6..e5b57257b97 100644
--- a/src/main/java/org/olat/course/nodes/CheckListCourseNode.java
+++ b/src/main/java/org/olat/course/nodes/CheckListCourseNode.java
@@ -742,6 +742,7 @@ public class CheckListCourseNode extends AbstractAccessableCourseNode implements
 				DBFactory.getInstance().commitAndCloseSession();
 			}
 		}
+		DBFactory.getInstance().commitAndCloseSession();
 		super.updateOnPublish(locale, course, publisher, publishEvents);
 	}
 	
-- 
GitLab