/*
 * 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.BigDecimal;
import java.math.BigInteger;
import java.util.Date;
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.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TGENECURRENCYRATE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgenecurrencyrate.findAll", query = "SELECT t FROM Tgenecurrencyrate t"),
    @NamedQuery(name = "Tgenecurrencyrate.findByCurrencycode", query = "SELECT t FROM Tgenecurrencyrate t WHERE t.tgenecurrencyratePK.currencycode = :currencycode"),
    @NamedQuery(name = "Tgenecurrencyrate.findByDateto", query = "SELECT t FROM Tgenecurrencyrate t WHERE t.tgenecurrencyratePK.dateto = :dateto"),
    @NamedQuery(name = "Tgenecurrencyrate.findByRecordversion", query = "SELECT t FROM Tgenecurrencyrate t WHERE t.recordversion = :recordversion"),
    @NamedQuery(name = "Tgenecurrencyrate.findByBuyrate", query = "SELECT t FROM Tgenecurrencyrate t WHERE t.buyrate = :buyrate"),
    @NamedQuery(name = "Tgenecurrencyrate.findBySellrate", query = "SELECT t FROM Tgenecurrencyrate t WHERE t.sellrate = :sellrate"),
    @NamedQuery(name = "Tgenecurrencyrate.findByDatefrom", query = "SELECT t FROM Tgenecurrencyrate t WHERE t.datefrom = :datefrom")})
public class Tgenecurrencyrate implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgenecurrencyratePK tgenecurrencyratePK;
    @Column(name = "RECORDVERSION")
    private BigInteger recordversion;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "BUYRATE")
    private BigDecimal buyrate;
    @Column(name = "SELLRATE")
    private BigDecimal sellrate;
    @Column(name = "DATEFROM")
    @Temporal(TemporalType.TIMESTAMP)
    private Date datefrom;
    @JoinColumn(name = "CURRENCYCODE", referencedColumnName = "CURRENCYCODE", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Tgenecurrency tgenecurrency;

    public Tgenecurrencyrate() {
    }

    public Tgenecurrencyrate(TgenecurrencyratePK tgenecurrencyratePK) {
        this.tgenecurrencyratePK = tgenecurrencyratePK;
    }

    public Tgenecurrencyrate(String currencycode, Date dateto) {
        this.tgenecurrencyratePK = new TgenecurrencyratePK(currencycode, dateto);
    }

    public TgenecurrencyratePK getTgenecurrencyratePK() {
        return tgenecurrencyratePK;
    }

    public void setTgenecurrencyratePK(TgenecurrencyratePK tgenecurrencyratePK) {
        this.tgenecurrencyratePK = tgenecurrencyratePK;
    }

    public BigInteger getRecordversion() {
        return recordversion;
    }

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

    public BigDecimal getBuyrate() {
        return buyrate;
    }

    public void setBuyrate(BigDecimal buyrate) {
        this.buyrate = buyrate;
    }

    public BigDecimal getSellrate() {
        return sellrate;
    }

    public void setSellrate(BigDecimal sellrate) {
        this.sellrate = sellrate;
    }

    public Date getDatefrom() {
        return datefrom;
    }

    public void setDatefrom(Date datefrom) {
        this.datefrom = datefrom;
    }

    public Tgenecurrency getTgenecurrency() {
        return tgenecurrency;
    }

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

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

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