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

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TGENESUBPRODUCT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgenesubproduct.findAll", query = "SELECT t FROM Tgenesubproduct t"),
    @NamedQuery(name = "Tgenesubproduct.findByModulecode", query = "SELECT t FROM Tgenesubproduct t WHERE t.tgenesubproductPK.modulecode = :modulecode"),
    @NamedQuery(name = "Tgenesubproduct.findByProductcode", query = "SELECT t FROM Tgenesubproduct t WHERE t.tgenesubproductPK.productcode = :productcode"),
    @NamedQuery(name = "Tgenesubproduct.findBySubproductcode", query = "SELECT t FROM Tgenesubproduct t WHERE t.tgenesubproductPK.subproductcode = :subproductcode"),
    @NamedQuery(name = "Tgenesubproduct.findByRecordversion", query = "SELECT t FROM Tgenesubproduct t WHERE t.recordversion = :recordversion"),
    @NamedQuery(name = "Tgenesubproduct.findByInitials", query = "SELECT t FROM Tgenesubproduct t WHERE t.initials = :initials"),
    @NamedQuery(name = "Tgenesubproduct.findByDescription", query = "SELECT t FROM Tgenesubproduct t WHERE t.description = :description")})
public class Tgenesubproduct implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgenesubproductPK tgenesubproductPK;
    @Column(name = "RECORDVERSION")
    private BigInteger recordversion;
    @Column(name = "INITIALS")
    private String initials;
    @Basic(optional = false)
    @Column(name = "DESCRIPTION")
    private String description;
    @JoinTable(name = "TGENESUBPRODREPORTS", joinColumns = {
        @JoinColumn(name = "MODULECODE", referencedColumnName = "MODULECODE"),
        @JoinColumn(name = "PRODUCTCODE", referencedColumnName = "PRODUCTCODE"),
        @JoinColumn(name = "SUBPRODUCTCODE", referencedColumnName = "SUBPRODUCTCODE")}, inverseJoinColumns = {
        @JoinColumn(name = "REPORTCODE", referencedColumnName = "REPORTCODE"),
        @JoinColumn(name = "MODULECODE", referencedColumnName = "MODULECODE")})
    @ManyToMany
    private Collection<Tgenereport> tgenereportCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenesubproduct")
    private Collection<Tgenesubproductcharges> tgenesubproductchargesCollection;
    @JoinColumns({
        @JoinColumn(name = "MODULECODE", referencedColumnName = "MODULECODE", insertable = false, updatable = false),
        @JoinColumn(name = "PRODUCTCODE", referencedColumnName = "PRODUCTCODE", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Tgeneproduct tgeneproduct;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenesubproduct")
    private Collection<Tgenesubproductcurrency> tgenesubproductcurrencyCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenesubproduct")
    private Collection<Tgenesubproductdesc> tgenesubproductdescCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenesubproduct")
    private Collection<Tsafeprofilehoraryamount> tsafeprofilehoraryamountCollection;

    public Tgenesubproduct() {
    }

    public Tgenesubproduct(TgenesubproductPK tgenesubproductPK) {
        this.tgenesubproductPK = tgenesubproductPK;
    }

    public Tgenesubproduct(TgenesubproductPK tgenesubproductPK, String description) {
        this.tgenesubproductPK = tgenesubproductPK;
        this.description = description;
    }

    public Tgenesubproduct(String modulecode, String productcode, String subproductcode) {
        this.tgenesubproductPK = new TgenesubproductPK(modulecode, productcode, subproductcode);
    }

    public TgenesubproductPK getTgenesubproductPK() {
        return tgenesubproductPK;
    }

    public void setTgenesubproductPK(TgenesubproductPK tgenesubproductPK) {
        this.tgenesubproductPK = tgenesubproductPK;
    }

    public BigInteger getRecordversion() {
        return recordversion;
    }

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

    public String getInitials() {
        return initials;
    }

    public void setInitials(String initials) {
        this.initials = initials;
    }

    public String getDescription() {
        return description;
    }

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

    @XmlTransient
    public Collection<Tgenereport> getTgenereportCollection() {
        return tgenereportCollection;
    }

    public void setTgenereportCollection(Collection<Tgenereport> tgenereportCollection) {
        this.tgenereportCollection = tgenereportCollection;
    }

    @XmlTransient
    public Collection<Tgenesubproductcharges> getTgenesubproductchargesCollection() {
        return tgenesubproductchargesCollection;
    }

    public void setTgenesubproductchargesCollection(Collection<Tgenesubproductcharges> tgenesubproductchargesCollection) {
        this.tgenesubproductchargesCollection = tgenesubproductchargesCollection;
    }

    public Tgeneproduct getTgeneproduct() {
        return tgeneproduct;
    }

    public void setTgeneproduct(Tgeneproduct tgeneproduct) {
        this.tgeneproduct = tgeneproduct;
    }

    @XmlTransient
    public Collection<Tgenesubproductcurrency> getTgenesubproductcurrencyCollection() {
        return tgenesubproductcurrencyCollection;
    }

    public void setTgenesubproductcurrencyCollection(Collection<Tgenesubproductcurrency> tgenesubproductcurrencyCollection) {
        this.tgenesubproductcurrencyCollection = tgenesubproductcurrencyCollection;
    }

    @XmlTransient
    public Collection<Tgenesubproductdesc> getTgenesubproductdescCollection() {
        return tgenesubproductdescCollection;
    }

    public void setTgenesubproductdescCollection(Collection<Tgenesubproductdesc> tgenesubproductdescCollection) {
        this.tgenesubproductdescCollection = tgenesubproductdescCollection;
    }

    @XmlTransient
    public Collection<Tsafeprofilehoraryamount> getTsafeprofilehoraryamountCollection() {
        return tsafeprofilehoraryamountCollection;
    }

    public void setTsafeprofilehoraryamountCollection(Collection<Tsafeprofilehoraryamount> tsafeprofilehoraryamountCollection) {
        this.tsafeprofilehoraryamountCollection = tsafeprofilehoraryamountCollection;
    }

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

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