Fix db error during account creation.

This commit is contained in:
Paulo Gustavo Veiga 2022-09-27 20:14:32 -07:00
parent 5f26874b47
commit aa6ac9bf7f
2 changed files with 6 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}