From 0d89655dedd59fbfb017934d3ce15452d486ab72 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 ada6a2e1c4..432c7f2c29 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 f9a298ccee..3c46ce0fe5 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 cdbdc6d39a..7f13d318d5 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 9b1e27d1de..57d43b9e33 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 { }