/** * 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.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlTransient; /** * * @author _rusty */ @Entity @Table(name = "commands") @XmlRootElement @NamedQueries({ @NamedQuery(name = "Command.findAll", query = "SELECT c FROM Command c"), @NamedQuery(name = "Command.findById", query = "SELECT c FROM Command c WHERE c.id = :id"), @NamedQuery(name = "Command.findByName", query = "SELECT c FROM Command c WHERE c.name = :name")}) public class Command implements Serializable { private static final long serialVersionUID = 1L; @Basic(optional = false) @Column(name = "ID") private int id; @Id @Basic(optional = false) @Column(name = "Name") private String name; @JoinTable(name = "grouppermissions", joinColumns = { @JoinColumn(name = "CommandID", referencedColumnName = "ID")}, inverseJoinColumns = { @JoinColumn(name = "GroupID", referencedColumnName = "ID")}) @ManyToMany private Collection usergroupCollection; public Command() { } public Command(String name) { this.name = name; } public Command(String name, int id) { this.name = name; this.id = id; } public int getId() { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @XmlTransient public Collection getUsergroupCollection() { return usergroupCollection; } public void setUsergroupCollection(Collection usergroupCollection) { this.usergroupCollection = usergroupCollection; } @Override public int hashCode() { int hash = 0; hash += (name != null ? name.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 Command)) { return false; } Command other = (Command) object; if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name))) { return false; } return true; } @Override public String toString() { return "gwlpr.database.entities.Command[ name=" + name + " ]"; } }