diff --git a/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java b/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java index a1d42cd73650c9f26b99766aa7caecc06d534d33..9d95bae384f744736df85234a3187ec84d9f5205 100644 --- a/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java +++ b/src/main/java/org/olat/admin/registration/SystemRegistrationManager.java @@ -292,6 +292,8 @@ public class SystemRegistrationManager implements InitializingBean { String email = registrationModule.getEmail(); msgProperties.put("email", email); } + + database.commitAndCloseSession(); return msgProperties; } diff --git a/src/main/java/org/olat/repository/RepositoryManager.java b/src/main/java/org/olat/repository/RepositoryManager.java index 9cbb20b9b76e6ab13f0811e558196e2bd2abcd2d..d033d501472aab08b0dbb5a05d12312713ea6e33 100644 --- a/src/main/java/org/olat/repository/RepositoryManager.java +++ b/src/main/java/org/olat/repository/RepositoryManager.java @@ -37,6 +37,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import javax.persistence.FlushModeType; import javax.persistence.TypedQuery; import org.apache.logging.log4j.Logger; @@ -1043,6 +1044,7 @@ public class RepositoryManager { List<Number> count = dbInstance.getCurrentEntityManager() .createQuery(query.toString(), Number.class) .setParameter("restrictedType", restrictedType) + .setFlushMode(FlushModeType.COMMIT) .getResultList(); return count == null || count.isEmpty() || count.get(0) == null ? null : count.get(0).intValue(); } diff --git a/src/main/java/org/olat/restapi/system/MonitoringService.java b/src/main/java/org/olat/restapi/system/MonitoringService.java index 0d04934a01eadcbd640578ba73d57b77557d94ff..410f41dbd5449651f48797eafa0ca9d800b67e86 100644 --- a/src/main/java/org/olat/restapi/system/MonitoringService.java +++ b/src/main/java/org/olat/restapi/system/MonitoringService.java @@ -22,6 +22,7 @@ package org.olat.restapi.system; import org.olat.admin.sysinfo.manager.DatabaseStatsManager; import org.olat.admin.sysinfo.model.DatabaseConnectionVO; import org.olat.basesecurity.BaseSecurity; +import org.olat.core.commons.persistence.DB; import org.olat.core.id.Identity; import org.olat.course.CourseModule; import org.olat.group.BusinessGroupService; @@ -44,13 +45,15 @@ import org.springframework.stereotype.Service; @Service public class MonitoringService { - private static final int RENEW_RATE = 60 * 60 * 1000;// once an hour + private static final int RENEW_RATE = 60 * 1000;// once an hour private long start; private long activeUserCountCached; private long totalGroupCountCached; private long publishedCoursesCached; + @Autowired + private DB dbInstance; @Autowired private BaseSecurity securityManager; @Autowired @@ -79,6 +82,7 @@ public class MonitoringService { activeUserCountCached = securityManager.countIdentitiesByPowerSearch(null, null, false, null, null, null, null, null, null, Identity.STATUS_ACTIV); totalGroupCountCached = businessGroupService.countBusinessGroups(null, null); publishedCoursesCached = repositoryManager.countPublished(CourseModule.ORES_TYPE_COURSE); + dbInstance.commitAndCloseSession(); } statistics.setActiveUserCount(activeUserCountCached); statistics.setTotalGroupCount(totalGroupCountCached); @@ -90,6 +94,7 @@ public class MonitoringService { statistics.setActiveConnectionCount(connections.getActiveConnectionCount()); statistics.setCurrentConnectionCount(connections.getCurrentConnectionCount()); } + dbInstance.commitAndCloseSession(); return statistics; } diff --git a/src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java b/src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java index 97f5ab48c75e421b3422957f1c994ba0c9190fa8..4b4f22bb747b8c2b92a50d6ba1a4daa82788ea45 100644 --- a/src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java +++ b/src/main/java/org/olat/restapi/system/OpenOLATStatisticsWebService.java @@ -33,6 +33,7 @@ import org.olat.admin.sysinfo.manager.SessionStatsManager; import org.olat.admin.sysinfo.model.SessionsStats; import org.olat.basesecurity.BaseSecurity; import org.olat.core.CoreSpringFactory; +import org.olat.core.commons.persistence.DBFactory; import org.olat.core.id.Identity; import org.olat.core.util.SessionInfo; import org.olat.core.util.UserSession; @@ -217,6 +218,7 @@ public class OpenOLATStatisticsWebService implements Sampler { BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class); long countGroups = bgs.countBusinessGroups(null, null); + DBFactory.getInstance().commitAndCloseSession(); stats.setTotalGroupCount(countGroups); return stats; } @@ -226,6 +228,7 @@ public class OpenOLATStatisticsWebService implements Sampler { RepositoryManager repoMgr = CoreSpringFactory.getImpl(RepositoryManager.class); int allCourses = repoMgr.countByType(CourseModule.ORES_TYPE_COURSE); int publishedCourses = repoMgr.countPublished(CourseModule.ORES_TYPE_COURSE); + DBFactory.getInstance().commitAndCloseSession(); stats.setCoursesCount(allCourses); stats.setPublishedCoursesCount(publishedCourses); return stats;