From be77d3046068bdc654a75d5ed931d480370fc745 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Fri, 24 Jan 2020 14:08:52 +0100 Subject: Make user.ownedRole relationship @OneToOne. Change-Id: I8c0194960e15192ba36834fa666c3f9fb2826df8 --- src/main/java/eu/mulk/mulkcms2/benki/accesscontrol/Role.java | 5 +++-- src/main/java/eu/mulk/mulkcms2/benki/users/User.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/main/java') 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 directUsers; - @OneToMany(mappedBy = "ownedRole", fetch = FetchType.LAZY) - public Collection owningUsers; + @OneToOne(mappedBy = "ownedRole", fetch = FetchType.LAZY) + public User owningUsers; @ManyToMany(mappedBy = "effectiveRoles", fetch = FetchType.LAZY) public Collection 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 rsaKeys; - @ManyToOne(fetch = FetchType.LAZY) + @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "role", referencedColumnName = "id", nullable = false) public Role ownedRole; -- cgit v1.2.3