/*
 * 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.math.BigInteger;
import java.util.Collection;
import javax.persistence.CascadeType;
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.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TGENEBRANCH")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgenebranch.findAll", query = "SELECT t FROM Tgenebranch t"),
    @NamedQuery(name = "Tgenebranch.findByBranchcode", query = "SELECT t FROM Tgenebranch t WHERE t.tgenebranchPK.branchcode = :branchcode"),
    @NamedQuery(name = "Tgenebranch.findByCompanycode", query = "SELECT t FROM Tgenebranch t WHERE t.tgenebranchPK.companycode = :companycode"),
    @NamedQuery(name = "Tgenebranch.findByRecordversion", query = "SELECT t FROM Tgenebranch t WHERE t.recordversion = :recordversion"),
    @NamedQuery(name = "Tgenebranch.findByDescription", query = "SELECT t FROM Tgenebranch t WHERE t.description = :description")})
public class Tgenebranch implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgenebranchPK tgenebranchPK;
    @Column(name = "RECORDVERSION")
    private BigInteger recordversion;
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenebranch")
    private Collection<Tgeneoffice> tgeneofficeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenebranch")
    private Collection<Tgeneaccountingdate> tgeneaccountingdateCollection;
    @JoinColumn(name = "COMPANYCODE", referencedColumnName = "COMPANYCODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tgenecompany tgenecompany;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "tgenebranch")
    private Tgeneaccountingdatebranch tgeneaccountingdatebranch;

    public Tgenebranch() {
    }

    public Tgenebranch(TgenebranchPK tgenebranchPK) {
        this.tgenebranchPK = tgenebranchPK;
    }

    public Tgenebranch(short branchcode, long companycode) {
        this.tgenebranchPK = new TgenebranchPK(branchcode, companycode);
    }

    public TgenebranchPK getTgenebranchPK() {
        return tgenebranchPK;
    }

    public void setTgenebranchPK(TgenebranchPK tgenebranchPK) {
        this.tgenebranchPK = tgenebranchPK;
    }

    public BigInteger getRecordversion() {
        return recordversion;
    }

    public void setRecordversion(BigInteger recordversion) {
        this.recordversion = recordversion;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @XmlTransient
    public Collection<Tgeneoffice> getTgeneofficeCollection() {
        return tgeneofficeCollection;
    }

    public void setTgeneofficeCollection(Collection<Tgeneoffice> tgeneofficeCollection) {
        this.tgeneofficeCollection = tgeneofficeCollection;
    }

    @XmlTransient
    public Collection<Tgeneaccountingdate> getTgeneaccountingdateCollection() {
        return tgeneaccountingdateCollection;
    }

    public void setTgeneaccountingdateCollection(Collection<Tgeneaccountingdate> tgeneaccountingdateCollection) {
        this.tgeneaccountingdateCollection = tgeneaccountingdateCollection;
    }

    public Tgenecompany getTgenecompany() {
        return tgenecompany;
    }

    public void setTgenecompany(Tgenecompany tgenecompany) {
        this.tgenecompany = tgenecompany;
    }

    public Tgeneaccountingdatebranch getTgeneaccountingdatebranch() {
        return tgeneaccountingdatebranch;
    }

    public void setTgeneaccountingdatebranch(Tgeneaccountingdatebranch tgeneaccountingdatebranch) {
        this.tgeneaccountingdatebranch = tgeneaccountingdatebranch;
    }

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

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