/*
 * 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.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.TGENEPRODUCT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgeneproduct.findAll", query = "SELECT t FROM Tgeneproduct t"),
    @NamedQuery(name = "Tgeneproduct.findByModulecode", query = "SELECT t FROM Tgeneproduct t WHERE t.tgeneproductPK.modulecode = :modulecode"),
    @NamedQuery(name = "Tgeneproduct.findByProductcode", query = "SELECT t FROM Tgeneproduct t WHERE t.tgeneproductPK.productcode = :productcode"),
    @NamedQuery(name = "Tgeneproduct.findByRecordversion", query = "SELECT t FROM Tgeneproduct t WHERE t.recordversion = :recordversion"),
    @NamedQuery(name = "Tgeneproduct.findByDescription", query = "SELECT t FROM Tgeneproduct t WHERE t.description = :description")})
public class Tgeneproduct implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgeneproductPK tgeneproductPK;
    @Column(name = "RECORDVERSION")
    private BigInteger recordversion;
    @Basic(optional = false)
    @Column(name = "DESCRIPTION")
    private String description;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgeneproduct")
    private Collection<Tgenesubproduct> tgenesubproductCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgeneproduct")
    private Collection<Tgeneproductdesc> tgeneproductdescCollection;
    @JoinColumn(name = "MODULECODE", referencedColumnName = "MODULECODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tgenemodule tgenemodule;

    public Tgeneproduct() {
    }

    public Tgeneproduct(TgeneproductPK tgeneproductPK) {
        this.tgeneproductPK = tgeneproductPK;
    }

    public Tgeneproduct(TgeneproductPK tgeneproductPK, String description) {
        this.tgeneproductPK = tgeneproductPK;
        this.description = description;
    }

    public Tgeneproduct(String modulecode, String productcode) {
        this.tgeneproductPK = new TgeneproductPK(modulecode, productcode);
    }

    public TgeneproductPK getTgeneproductPK() {
        return tgeneproductPK;
    }

    public void setTgeneproductPK(TgeneproductPK tgeneproductPK) {
        this.tgeneproductPK = tgeneproductPK;
    }

    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<Tgenesubproduct> getTgenesubproductCollection() {
        return tgenesubproductCollection;
    }

    public void setTgenesubproductCollection(Collection<Tgenesubproduct> tgenesubproductCollection) {
        this.tgenesubproductCollection = tgenesubproductCollection;
    }

    @XmlTransient
    public Collection<Tgeneproductdesc> getTgeneproductdescCollection() {
        return tgeneproductdescCollection;
    }

    public void setTgeneproductdescCollection(Collection<Tgeneproductdesc> tgeneproductdescCollection) {
        this.tgeneproductdescCollection = tgeneproductdescCollection;
    }

    public Tgenemodule getTgenemodule() {
        return tgenemodule;
    }

    public void setTgenemodule(Tgenemodule tgenemodule) {
        this.tgenemodule = tgenemodule;
    }

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

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