From 55c104cfbe29075f9697b2f8c5fa6625f549cb2e Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Mon, 20 Nov 2023 07:27:56 -0800 Subject: [PATCH] fix lazy initialization error. --- wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java | 2 +- .../src/main/java/com/wisemapping/rest/MindmapController.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java b/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java index 5c273b83..64253a33 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Mindmap.java @@ -65,7 +65,7 @@ public class Mindmap implements Serializable { @Column(name = "public") private boolean isPublic; - @OneToMany(mappedBy = "mindMap", orphanRemoval = true, cascade = {CascadeType.ALL}, fetch = FetchType.LAZY) + @OneToMany(mappedBy = "mindMap", orphanRemoval = true, cascade = {CascadeType.ALL}, fetch = FetchType.EAGER) @Fetch(FetchMode.JOIN) private Set collaborations = new HashSet<>(); diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java index 8e7d309e..29e3fed7 100644 --- a/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java +++ b/wise-webapp/src/main/java/com/wisemapping/rest/MindmapController.java @@ -24,6 +24,7 @@ import com.wisemapping.rest.model.*; import com.wisemapping.security.Utils; import com.wisemapping.service.*; import com.wisemapping.validator.MapInfoValidator; +import jakarta.transaction.Transactional; import org.apache.commons.validator.routines.EmailValidator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -47,6 +48,7 @@ import java.util.stream.Collectors; @Controller +@Transactional @PreAuthorize("isAuthenticated() and hasRole('ROLE_USER')") public class MindmapController extends BaseController { final Logger logger = LogManager.getLogger();