summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-01-24 14:08:52 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-01-24 14:08:52 +0100
commitbe77d3046068bdc654a75d5ed931d480370fc745 (patch)
tree85f7b35aa88345877a10611a5fa9d03da28c6352
parent24a25144eaaf1c0a13b7fe746a1e453010dd14cf (diff)
Make user.ownedRole relationship @OneToOne.
Change-Id: I8c0194960e15192ba36834fa666c3f9fb2826df8
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/accesscontrol/Role.java5
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/users/User.java4
2 files changed, 5 insertions, 4 deletions
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.JoinColumn;
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 @@ public class Role extends PanacheEntityBase {
@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.Id;
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 @@ public class User extends PanacheEntityBase {
@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;