Make user.ownedRole relationship @OneToOne.
Change-Id: I8c0194960e15192ba36834fa666c3f9fb2826df8
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/accesscontrol/Role.java b/src/main/java/eu/mulk/mulkcms2/benki/accesscontrol/Role.java
index 131fb69..b7dd6fc 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/accesscontrol/Role.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/accesscontrol/Role.java
@@ -17,6 +17,7 @@
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@@ -59,8 +60,8 @@
@OneToMany(mappedBy = "role", fetch = FetchType.LAZY)
public Collection<UserRole> directUsers;
- @OneToMany(mappedBy = "ownedRole", fetch = FetchType.LAZY)
- public Collection<User> owningUsers;
+ @OneToOne(mappedBy = "ownedRole", fetch = FetchType.LAZY)
+ public User owningUsers;
@ManyToMany(mappedBy = "effectiveRoles", fetch = FetchType.LAZY)
public Collection<User> effectiveUsers;
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/users/User.java b/src/main/java/eu/mulk/mulkcms2/benki/users/User.java
index 90b3318..6e16903 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/users/User.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/users/User.java
@@ -16,8 +16,8 @@
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity(name = "BenkiUser")
@@ -79,7 +79,7 @@
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY)
public Collection<UserRsaKey> rsaKeys;
- @ManyToOne(fetch = FetchType.LAZY)
+ @OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "role", referencedColumnName = "id", nullable = false)
public Role ownedRole;