Commit 6b44766d by Tuukka Kivilahti

changet database, keep fun

1 parent 982acbb6
......@@ -45,9 +45,6 @@ public class AccessRight implements ModelInterface {
@Column(name = "right_description")
private String description;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "accessRight")
private List<NewsGroup> newsGroups;
@OneToMany(mappedBy = "accessRight")
private List<RoleRight> roleRights;
......@@ -87,14 +84,6 @@ public class AccessRight implements ModelInterface {
this.name = accessRight;
}
public List<NewsGroup> getNewsGroupList() {
return newsGroups;
}
public void setNewsGroupList(List<NewsGroup> newsGroupList) {
this.newsGroups = newsGroupList;
}
public List<RoleRight> getRoleRightList() {
return roleRights;
}
......
......@@ -13,8 +13,9 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
......@@ -51,9 +52,9 @@ public class NewsGroup implements ModelInterface {
@Column(name = "priority", nullable = false)
private int priority;
@JoinColumn(name = "access_rights_id", referencedColumnName = "access_rights_id", nullable = false)
@ManyToOne(optional = false)
private AccessRight accessRight;
@ManyToMany
@JoinTable(name = "roles_news_groups", joinColumns = @JoinColumn(name = "news_groups_id", referencedColumnName = "news_groups_id"), inverseJoinColumns = @JoinColumn(name = "roles_id", referencedColumnName = "roles_id"))
private List<Role> roles;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "group")
private List<News> news;
......@@ -99,14 +100,6 @@ public class NewsGroup implements ModelInterface {
this.priority = priority;
}
public AccessRight getAccessRight() {
return accessRight;
}
public void setAccessRight(AccessRight accessRightsId) {
this.accessRight = accessRightsId;
}
public List<News> getNews() {
return news;
}
......@@ -176,4 +169,18 @@ public class NewsGroup implements ModelInterface {
public void setJpaVersionField(int jpaVersionField) {
this.jpaVersionField = jpaVersionField;
}
/**
* @return the roles
*/
public List<Role> getRoles() {
return roles;
}
/**
* @param roles the roles to set
*/
public void setRoles(List<Role> roles) {
this.roles = roles;
}
}
......@@ -67,10 +67,14 @@ public class Role implements ModelInterface {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "role")
private List<Discount> discounts;
@ManyToMany(mappedBy = "roles")
private List<NewsGroup> newsGroups;
@Version
@Column(nullable = false)
private int jpaVersionField;
public Role() {
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!