Commit 2b75e123 by Juho Juopperi

OrgRole and Role ManyToMany

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