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

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TGENESUBPRODUCTCURRENCY")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgenesubproductcurrency.findAll", query = "SELECT t FROM Tgenesubproductcurrency t"),
    @NamedQuery(name = "Tgenesubproductcurrency.findByModulecode", query = "SELECT t FROM Tgenesubproductcurrency t WHERE t.tgenesubproductcurrencyPK.modulecode = :modulecode"),
    @NamedQuery(name = "Tgenesubproductcurrency.findByProductcode", query = "SELECT t FROM Tgenesubproductcurrency t WHERE t.tgenesubproductcurrencyPK.productcode = :productcode"),
    @NamedQuery(name = "Tgenesubproductcurrency.findBySubproductcode", query = "SELECT t FROM Tgenesubproductcurrency t WHERE t.tgenesubproductcurrencyPK.subproductcode = :subproductcode"),
    @NamedQuery(name = "Tgenesubproductcurrency.findByCurrencycode", query = "SELECT t FROM Tgenesubproductcurrency t WHERE t.tgenesubproductcurrencyPK.currencycode = :currencycode")})
public class Tgenesubproductcurrency implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgenesubproductcurrencyPK tgenesubproductcurrencyPK;
    @JoinColumn(name = "CURRENCYCODE", referencedColumnName = "CURRENCYCODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tgenecurrency tgenecurrency;
    @JoinColumns({
        @JoinColumn(name = "MODULECODE", referencedColumnName = "MODULECODE", insertable = false, updatable = false),
        @JoinColumn(name = "PRODUCTCODE", referencedColumnName = "PRODUCTCODE", insertable = false, updatable = false),
        @JoinColumn(name = "SUBPRODUCTCODE", referencedColumnName = "SUBPRODUCTCODE", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Tgenesubproduct tgenesubproduct;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenesubproductcurrency")
    private Collection<Tgenesubproductrate> tgenesubproductrateCollection;

    public Tgenesubproductcurrency() {
    }

    public Tgenesubproductcurrency(TgenesubproductcurrencyPK tgenesubproductcurrencyPK) {
        this.tgenesubproductcurrencyPK = tgenesubproductcurrencyPK;
    }

    public Tgenesubproductcurrency(String modulecode, String productcode, String subproductcode, String currencycode) {
        this.tgenesubproductcurrencyPK = new TgenesubproductcurrencyPK(modulecode, productcode, subproductcode, currencycode);
    }

    public TgenesubproductcurrencyPK getTgenesubproductcurrencyPK() {
        return tgenesubproductcurrencyPK;
    }

    public void setTgenesubproductcurrencyPK(TgenesubproductcurrencyPK tgenesubproductcurrencyPK) {
        this.tgenesubproductcurrencyPK = tgenesubproductcurrencyPK;
    }

    public Tgenecurrency getTgenecurrency() {
        return tgenecurrency;
    }

    public void setTgenecurrency(Tgenecurrency tgenecurrency) {
        this.tgenecurrency = tgenecurrency;
    }

    public Tgenesubproduct getTgenesubproduct() {
        return tgenesubproduct;
    }

    public void setTgenesubproduct(Tgenesubproduct tgenesubproduct) {
        this.tgenesubproduct = tgenesubproduct;
    }

    @XmlTransient
    public Collection<Tgenesubproductrate> getTgenesubproductrateCollection() {
        return tgenesubproductrateCollection;
    }

    public void setTgenesubproductrateCollection(Collection<Tgenesubproductrate> tgenesubproductrateCollection) {
        this.tgenesubproductrateCollection = tgenesubproductrateCollection;
    }

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

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