/** * For copyright information see the LICENSE document. */ package gwlpr.database.entities; import java.io.Serializable; import java.util.Collection; import javax.persistence.Basic; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author _rusty */ @Entity @Table(name = "attributes") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Attribute.findAll", query = "SELECT a FROM Attribute a"), @NamedQuery(name = "Attribute.findById", query = "SELECT a FROM Attribute a WHERE a.id = :id"), @NamedQuery(name = "Attribute.findByName", query = "SELECT a FROM Attribute a WHERE a.name = :name")}) public class Attribute implements Serializable { private static final long serialVersionUID = 1L; @Id @Basic(optional = false) @Column(name = "ID") private Integer id; @Basic(optional = false) @Column(name = "Name") private String name; @OneToMany(cascade = CascadeType.ALL, mappedBy = "attribute") private Collection skillCollection; @JoinColumn(name = "Profession", referencedColumnName = "ID") @ManyToOne(optional = false) private Profession profession; @OneToMany(cascade = CascadeType.ALL, mappedBy = "attribute") private Collection attributepointCollection; public Attribute() { } public Attribute(Integer id) { this.id = id; } public Attribute(Integer id, String name) { this.id = id; this.name = name; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @XmlTransient public Collection getSkillCollection() { return skillCollection; } public void setSkillCollection(Collection skillCollection) { this.skillCollection = skillCollection; } public Profession getProfession() { return profession; } public void setProfession(Profession profession) { this.profession = profession; } @XmlTransient public Collection getAttributepointCollection() { return attributepointCollection; } public void setAttributepointCollection(Collection attributepointCollection) { this.attributepointCollection = attributepointCollection; } @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 Attribute)) { return false; } Attribute other = (Attribute) object; if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) { return false; } return true; } @Override public String toString() { return "gwlpr.database.entities.Attribute[ id=" + id + " ]"; } }