/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package ee.tlu.htk.dippler.entities; import java.io.Serializable; import javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.OneToOne; import javax.persistence.Table; import javax.persistence.TableGenerator; /** * * @author metz */ @Entity @Table(name = "client") @NamedQueries({ @NamedQuery(name = "Client.findAll", query = "SELECT c FROM Client c"), @NamedQuery(name = "Client.findById", query = "SELECT c FROM Client c WHERE c.id = :id"), @NamedQuery(name = "Client.findByUsername", query = "SELECT c FROM Client c WHERE c.username = :username"), @NamedQuery(name = "Client.findByPassword", query = "SELECT c FROM Client c WHERE c.password = :password"), @NamedQuery(name = "Client.findByClient", query = "SELECT c FROM Client c WHERE c.client = :client"), @NamedQuery(name = "Client.findByTrusted", query = "SELECT c FROM Client c WHERE c.trusted = :trusted"), @NamedQuery(name = "Client.findClient", query = "SELECT c FROM Client c WHERE c.password = :password AND c.username = :username") }) public class Client implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(generator = "ClientID") @TableGenerator(name="ClientID", table="id_gen", pkColumnName="ID_NAME", valueColumnName = "ID_VAL", pkColumnValue="LAST_CLIENT", allocationSize=1) @Basic(optional = false) @Column(name = "id") private Long id; @Basic(optional = false) @Column(name = "username") private String username; @Column(name = "password") private String password; @Column(name = "client") private String client; @Basic(optional = false) @Column(name = "trusted") private boolean trusted; @JoinColumn(name = "organization", referencedColumnName = "id") @OneToOne private Organization organization; public Client() { } public Client(Long id) { this.id = id; } public Client(Long id, String username, boolean trusted) { this.id = id; this.username = username; this.trusted = trusted; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getUsername() { return username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getClient() { return client; } public void setClient(String client) { this.client = client; } public boolean getTrusted() { return trusted; } public void setTrusted(boolean trusted) { this.trusted = trusted; } public Organization getOrganization() { return organization; } public void setOrganization(Organization organization) { this.organization = organization; } @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 Client)) { return false; } Client other = (Client) 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 "ee.tlu.htk.dippler.entities.Client[id=" + id + "]"; } }