/* * 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.OneToMany; import javax.persistence.Table; import org.eclipse.persistence.annotations.CascadeOnDelete; import org.hibernate.validator.constraints.NotEmpty; /** * * @author Toto-Works */ @Entity @Table(name = "core_module") @CascadeOnDelete public class Module implements Serializable { private static long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @NotEmpty(message = "Champ nom obligatoire") @Column(nullable = false, unique = true) private String name; @NotEmpty(message = "Champ alias obligatoire") @Column(nullable = false, unique = true) private String url; @OneToMany(mappedBy = "module", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY) @CascadeOnDelete private List features; @ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @JoinTable(name = "modules_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 url */ public String getUrl() { return url; } /** * @param url the name to set */ public void setUrl(String url) { this.url = url; } /** * @return the features */ public List getFeatures() { return features; } /** * @param features the features to set */ public void setFeatures(List features) { this.setFeatures(features); } /** * @return the permissions */ public List getPermissions() { return permissions; } /** * @param permissions the permissions to set */ public void setPermissions(List permissions) { this.setPermissions(permissions); } @Override public int hashCode() { int hash = 0; hash += (getId() != null ? getId().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 Module)) { return false; } Module other = (Module) object; return (this.getId() != null || other.getId() == null) && (this.getId() == null || this.id.equals(other.id)); } @Override public String toString() { return "veolia.core.entities.Module[ id=" + getId() + " ]"; } }