From aa6ac9bf7f3f000c3a325470dd54664f25cf60de Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 27 Sep 2022 20:14:32 -0700 Subject: [PATCH] Fix db error during account creation. --- .../main/java/com/wisemapping/dao/UserManagerImpl.java | 2 +- .../main/java/com/wisemapping/model/Collaboration.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java index 663fe9d2..bea65dcd 100644 --- a/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java +++ b/wise-webapp/src/main/java/com/wisemapping/dao/UserManagerImpl.java @@ -115,6 +115,7 @@ public class UserManagerImpl Collaboration newCollab = new Collaboration(); newCollab.setRoleId(oldCollab.getRole().ordinal()); newCollab.setMindMap(oldCollab.getMindMap()); + oldCollab.getMindMap().removedCollaboration(oldCollab); newCollab.setCollaborator(user); user.addCollaboration(newCollab); newCollabs.add(newCollab); @@ -124,7 +125,6 @@ public class UserManagerImpl final HibernateTemplate template = getHibernateTemplate(); collaborations.forEach(c -> template.delete(c)); template.delete(collaborator); - template.flush(); // Save all new... this.createUser(user); diff --git a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java index 0ab3ce73..7446b6f5 100644 --- a/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java +++ b/wise-webapp/src/main/java/com/wisemapping/model/Collaboration.java @@ -21,6 +21,7 @@ package com.wisemapping.model; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; +import org.jetbrains.annotations.Nullable; import javax.persistence.*; import javax.validation.constraints.NotNull; @@ -46,7 +47,7 @@ public class Collaboration implements Serializable { private Collaborator collaborator; @ManyToOne(cascade = CascadeType.ALL) - @JoinColumn(name = "properties_id", nullable = false, unique = true) + @JoinColumn(name = "properties_id", nullable = true, unique = true) private CollaborationProperties collaborationProperties = new CollaborationProperties(); public Collaboration() { @@ -103,12 +104,13 @@ public class Collaboration implements Serializable { this.collaborator = collaborator; } - @NotNull + + @Nullable public CollaborationProperties getCollaborationProperties() { return this.collaborationProperties; } - public void setCollaborationProperties(@NotNull CollaborationProperties collaborationProperties) { + public void setCollaborationProperties(@Nullable CollaborationProperties collaborationProperties) { this.collaborationProperties = collaborationProperties; }