/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.qsoft.rs.sincoar.model;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TSAFEUSERSESSION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tsafeusersession.findAll", query = "SELECT t FROM Tsafeusersession t"),
    @NamedQuery(name = "Tsafeusersession.findByUsercode", query = "SELECT t FROM Tsafeusersession t WHERE t.tsafeusersessionPK.usercode = :usercode"),
    @NamedQuery(name = "Tsafeusersession.findByDateto", query = "SELECT t FROM Tsafeusersession t WHERE t.tsafeusersessionPK.dateto = :dateto"),
    @NamedQuery(name = "Tsafeusersession.findByDatefrom", query = "SELECT t FROM Tsafeusersession t WHERE t.datefrom = :datefrom"),
    @NamedQuery(name = "Tsafeusersession.findByTerminalcode", query = "SELECT t FROM Tsafeusersession t WHERE t.terminalcode = :terminalcode"),
    @NamedQuery(name = "Tsafeusersession.findByTrynumber", query = "SELECT t FROM Tsafeusersession t WHERE t.trynumber = :trynumber"),
    @NamedQuery(name = "Tsafeusersession.findBySessionid", query = "SELECT t FROM Tsafeusersession t WHERE t.sessionid = :sessionid"),
    @NamedQuery(name = "Tsafeusersession.findByWebserverip", query = "SELECT t FROM Tsafeusersession t WHERE t.webserverip = :webserverip")})
public class Tsafeusersession implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TsafeusersessionPK tsafeusersessionPK;
    @Column(name = "DATEFROM")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datefrom;
    @Column(name = "TERMINALCODE")
    private String terminalcode;
    @Column(name = "TRYNUMBER")
    private Short trynumber;
    @Column(name = "SESSIONID")
    private String sessionid;
    @Column(name = "WEBSERVERIP")
    private String webserverip;
    @JoinColumn(name = "USERCODE", referencedColumnName = "USERCODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tsafeuser tsafeuser;

    public Tsafeusersession() {
    }

    public Tsafeusersession(TsafeusersessionPK tsafeusersessionPK) {
        this.tsafeusersessionPK = tsafeusersessionPK;
    }

    public Tsafeusersession(String usercode, Date dateto) {
        this.tsafeusersessionPK = new TsafeusersessionPK(usercode, dateto);
    }

    public TsafeusersessionPK getTsafeusersessionPK() {
        return tsafeusersessionPK;
    }

    public void setTsafeusersessionPK(TsafeusersessionPK tsafeusersessionPK) {
        this.tsafeusersessionPK = tsafeusersessionPK;
    }

    public Date getDatefrom() {
        return datefrom;
    }

    public void setDatefrom(Date datefrom) {
        this.datefrom = datefrom;
    }

    public String getTerminalcode() {
        return terminalcode;
    }

    public void setTerminalcode(String terminalcode) {
        this.terminalcode = terminalcode;
    }

    public Short getTrynumber() {
        return trynumber;
    }

    public void setTrynumber(Short trynumber) {
        this.trynumber = trynumber;
    }

    public String getSessionid() {
        return sessionid;
    }

    public void setSessionid(String sessionid) {
        this.sessionid = sessionid;
    }

    public String getWebserverip() {
        return webserverip;
    }

    public void setWebserverip(String webserverip) {
        this.webserverip = webserverip;
    }

    public Tsafeuser getTsafeuser() {
        return tsafeuser;
    }

    public void setTsafeuser(Tsafeuser tsafeuser) {
        this.tsafeuser = tsafeuser;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tsafeusersessionPK != null ? tsafeusersessionPK.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 Tsafeusersession)) {
            return false;
        }
        Tsafeusersession other = (Tsafeusersession) object;
        if ((this.tsafeusersessionPK == null && other.tsafeusersessionPK != null) || (this.tsafeusersessionPK != null && !this.tsafeusersessionPK.equals(other.tsafeusersessionPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsoft.rs.sincoar.model.Tsafeusersession[ tsafeusersessionPK=" + tsafeusersessionPK + " ]";
    }
    
}
