Commit 2b75e123 by Juho Juopperi

OrgRole and Role ManyToMany

1 parent 267cc600
...@@ -51,7 +51,7 @@ public class OrgRole extends GenericEntity { ...@@ -51,7 +51,7 @@ public class OrgRole extends GenericEntity {
@ManyToOne() @ManyToOne()
private EventOrganiser eventOrganizer; private EventOrganiser eventOrganizer;
@OneToMany @ManyToMany(mappedBy = "orgRoles")
private List<Role> eventRoles; private List<Role> eventRoles;
public OrgRole() { public OrgRole() {
......
...@@ -31,7 +31,7 @@ public class Role extends GenericEntity { ...@@ -31,7 +31,7 @@ public class Role extends GenericEntity {
protected static final String NAME_COLUMN = "role_name"; protected static final String NAME_COLUMN = "role_name";
protected static final String EVENT_ID_COLUMN = "event_id"; protected static final String EVENT_ID_COLUMN = "event_id";
protected static final String ORG_ROLE_ID_COLUMN = "org_role_id"; protected static final String ORG_ROLE_ID_COLUMN = "org_role_id";
public static final Role EMPTY_ROLE = new Role("----"); public static final Role EMPTY_ROLE = new Role("----");
...@@ -76,10 +76,12 @@ public class Role extends GenericEntity { ...@@ -76,10 +76,12 @@ public class Role extends GenericEntity {
@ManyToOne @ManyToOne
@JoinColumn(name = EVENT_ID_COLUMN, nullable = false) @JoinColumn(name = EVENT_ID_COLUMN, nullable = false)
private LanEvent event; private LanEvent event;
@ManyToOne @ManyToMany
@JoinColumn(name = ORG_ROLE_ID_COLUMN) @JoinTable(name = "roles_provided_by_org_roles",
private OrgRole orgRole; joinColumns = { @JoinColumn(name = "role_id", referencedColumnName = Role.ID_COLUMN) },
inverseJoinColumns = { @JoinColumn(name = "org_role_id", referencedColumnName = OrgRole.ID_COLUMN) })
private List<OrgRole> orgRoles;
public Role() { public Role() {
super(); super();
...@@ -196,12 +198,12 @@ public class Role extends GenericEntity { ...@@ -196,12 +198,12 @@ public class Role extends GenericEntity {
this.users = users; this.users = users;
} }
public OrgRole getOrgRole() { public List<OrgRole> getOrgRoles() {
return orgRole; return orgRoles;
} }
public void setOrgRole(OrgRole orgRole) { public void setOrgRoles(List<OrgRole> orgRoles) {
this.orgRole = orgRole; this.orgRoles = orgRoles;
} }
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!