From a02c7b721a12b516b945ba762f34b6fecd41c91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20B=C3=A9gaudeau?= Date: Fri, 21 Jun 2024 17:00:33 +0200 Subject: [PATCH] [cleanup] Fix dangling transactions which were not properly commited MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Bégaudeau --- .../services/EditingContextPersistenceService.java | 2 ++ .../editingcontext/services/EditingContextSearchService.java | 3 +++ .../application/studio/services/EditingContextInitializer.java | 2 ++ .../web/infrastructure/persistence/JDBCConfiguration.java | 2 ++ 4 files changed, 9 insertions(+) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.java index ada6a2e1c49..432c7f2c294 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextPersistenceService.java @@ -31,6 +31,7 @@ import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataUpdateService; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Timer; @@ -61,6 +62,7 @@ public EditingContextPersistenceService(ISemanticDataUpdateService semanticDataU } @Override + @Transactional public void persist(IEditingContext editingContext) { long start = System.currentTimeMillis(); diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java index f9a298cceef..3c46ce0fe5a 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/editingcontext/services/EditingContextSearchService.java @@ -43,6 +43,7 @@ import org.slf4j.LoggerFactory; import org.springframework.data.jdbc.core.mapping.AggregateReference; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.Timer; @@ -85,6 +86,7 @@ public EditingContextSearchService(IProjectSearchService projectSearchService, I } @Override + @Transactional(readOnly = true) public boolean existsById(String editingContextId) { return new UUIDParser().parse(editingContextId) .map(AggregateReference::to) @@ -93,6 +95,7 @@ public boolean existsById(String editingContextId) { } @Override + @Transactional(readOnly = true) public Optional findById(String editingContextId) { return new UUIDParser().parse(editingContextId) .flatMap(this.projectSearchService::findById) diff --git a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/EditingContextInitializer.java b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/EditingContextInitializer.java index cdbdc6d39a4..7f13d318d5d 100644 --- a/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/EditingContextInitializer.java +++ b/packages/sirius-web/backend/sirius-web-application/src/main/java/org/eclipse/sirius/web/application/studio/services/EditingContextInitializer.java @@ -37,6 +37,7 @@ import org.eclipse.sirius.web.application.studio.services.api.IStudioColorPalettesLoader; import org.eclipse.sirius.web.domain.boundedcontexts.semanticdata.services.api.ISemanticDataSearchService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** * Used to contribute the domain and view models found to the editing context. @@ -62,6 +63,7 @@ public EditingContextInitializer(ISemanticDataSearchService semanticDataSearchSe } @Override + @Transactional(readOnly = true) public void preProcess(IEditingContext editingContext) { if (editingContext instanceof EditingContext siriusWebEditingContext) { List domains = new ArrayList<>(); diff --git a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/persistence/JDBCConfiguration.java b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/persistence/JDBCConfiguration.java index 9b1e27d1de7..57d43b9e33b 100644 --- a/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/persistence/JDBCConfiguration.java +++ b/packages/sirius-web/backend/sirius-web-infrastructure/src/main/java/org/eclipse/sirius/web/infrastructure/persistence/JDBCConfiguration.java @@ -14,6 +14,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories; +import org.springframework.transaction.annotation.EnableTransactionManagement; /** * Spring Data JDBC configuration. @@ -21,6 +22,7 @@ * @author sbegaudeau */ @Configuration +@EnableTransactionManagement @EnableJdbcRepositories(basePackages = { "org.eclipse.sirius.web.domain" }) public class JDBCConfiguration { }