/*
 * 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 javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TSAFEUSERCOMPANY")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tsafeusercompany.findAll", query = "SELECT t FROM Tsafeusercompany t"),
    @NamedQuery(name = "Tsafeusercompany.findByUsercode", query = "SELECT t FROM Tsafeusercompany t WHERE t.tsafeusercompanyPK.usercode = :usercode"),
    @NamedQuery(name = "Tsafeusercompany.findByCompanycode", query = "SELECT t FROM Tsafeusercompany t WHERE t.tsafeusercompanyPK.companycode = :companycode"),
    @NamedQuery(name = "Tsafeusercompany.findBySecuritylevel", query = "SELECT t FROM Tsafeusercompany t WHERE t.securitylevel = :securitylevel")})
public class Tsafeusercompany implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TsafeusercompanyPK tsafeusercompanyPK;
    @Basic(optional = false)
    @Column(name = "SECURITYLEVEL")
    private short securitylevel;
    @JoinColumns({
        @JoinColumn(name = "OFFICECODE", referencedColumnName = "OFFICECODE"),
        @JoinColumn(name = "BRANCHCODE", referencedColumnName = "BRANCHCODE"),
        @JoinColumn(name = "COMPANYCODE", referencedColumnName = "COMPANYCODE", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Tgeneoffice tgeneoffice;
    @JoinColumn(name = "USERCODE", referencedColumnName = "USERCODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tsafeuser tsafeuser;

    public Tsafeusercompany() {
    }

    public Tsafeusercompany(TsafeusercompanyPK tsafeusercompanyPK) {
        this.tsafeusercompanyPK = tsafeusercompanyPK;
    }

    public Tsafeusercompany(TsafeusercompanyPK tsafeusercompanyPK, short securitylevel) {
        this.tsafeusercompanyPK = tsafeusercompanyPK;
        this.securitylevel = securitylevel;
    }

    public Tsafeusercompany(String usercode, long companycode) {
        this.tsafeusercompanyPK = new TsafeusercompanyPK(usercode, companycode);
    }

    public TsafeusercompanyPK getTsafeusercompanyPK() {
        return tsafeusercompanyPK;
    }

    public void setTsafeusercompanyPK(TsafeusercompanyPK tsafeusercompanyPK) {
        this.tsafeusercompanyPK = tsafeusercompanyPK;
    }

    public short getSecuritylevel() {
        return securitylevel;
    }

    public void setSecuritylevel(short securitylevel) {
        this.securitylevel = securitylevel;
    }

    public Tgeneoffice getTgeneoffice() {
        return tgeneoffice;
    }

    public void setTgeneoffice(Tgeneoffice tgeneoffice) {
        this.tgeneoffice = tgeneoffice;
    }

    public Tsafeuser getTsafeuser() {
        return tsafeuser;
    }

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

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

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