/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package veolia.core.entities; import java.io.Serializable; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.Table; import org.eclipse.persistence.annotations.CascadeOnDelete; import org.hibernate.validator.constraints.NotEmpty; /** * * @author Toto-Works */ @Entity @Table(name="core_group") public class Group implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotEmpty(message="Champ nom obligatoire") @Column(nullable=true, unique=true) private String name; @ManyToMany(mappedBy = "groups", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @CascadeOnDelete private List users; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name="groups_permissions") @CascadeOnDelete private List permissions; public Long getId() { return id; } public void setId(Long id) { this.id = id; } /** * @return the name */ public String getName() { return name; } /** * @param name the name to set */ public void setName(String name) { this.name = name; } /** * @return the users */ public List getUsers() { return users; } /** * @param users the users to set */ public void setUsers(List users) { this.users = users; } /** * @return the permissions */ public List getPermissions() { return permissions; } /** * @param permissions the permissions to set */ public void setPermissions(List permissions) { this.permissions = permissions; } @Override public int hashCode() { int hash = 0; hash += (id != null ? id.hashCode() : 0); return hash; } @Override public boolean equals(Object object) { // TODO: Warning - this method won't work in the case the id fields are not set if (!(object instanceof Group)) { return false; } Group other = (Group) object; return (this.id != null || other.id == null) && (this.id == null || this.id.equals(other.id)); } @Override public String toString() { return "veolia.core.entities.Group[ id=" + id + " ]"; } }