/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cosmodas.EntCosmos;

import java.io.Serializable;
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.xml.bind.annotation.XmlRootElement;

/**
 * @author obper
 */
@Entity
@Table(name = "articulo_sala")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "ArticuloSala.findAll", query = "SELECT a FROM ArticuloSala a"),
        @NamedQuery(name = "ArticuloSala.findByArticuloCodigo", query = "SELECT a FROM ArticuloSala a WHERE a.articuloSalaPK.articuloCodigo = :articuloCodigo"),
        @NamedQuery(name = "ArticuloSala.findBySucursalCodigo", query = "SELECT a FROM ArticuloSala a WHERE a.articuloSalaPK.sucursalCodigo = :sucursalCodigo"),
        @NamedQuery(name = "ArticuloSala.findByArticuloExistenciaFisica", query = "SELECT a FROM ArticuloSala a WHERE a.articuloExistenciaFisica = :articuloExistenciaFisica"),
        @NamedQuery(name = "ArticuloSala.findByArticuloExistenciaActual", query = "SELECT a FROM ArticuloSala a WHERE a.articuloExistenciaActual = :articuloExistenciaActual"),
        @NamedQuery(name = "ArticuloSala.findByArticuloExistenciaAnterior", query = "SELECT a FROM ArticuloSala a WHERE a.articuloExistenciaAnterior = :articuloExistenciaAnterior")})
public class ArticuloSala implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ArticuloSalaPK articuloSalaPK;
    @Column(name = "articulo_existencia_fisica")
    private Long articuloExistenciaFisica;
    @Column(name = "articulo_existencia_actual")
    private Long articuloExistenciaActual;
    @Column(name = "articulo_existencia_anterior")
    private Long articuloExistenciaAnterior;
    @JoinColumn(name = "articulo_codigo", referencedColumnName = "articulo_codigo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Articulo articulo;

    public ArticuloSala() {
    }

    public ArticuloSala(ArticuloSalaPK articuloSalaPK) {
        this.articuloSalaPK = articuloSalaPK;
    }

    public ArticuloSala(String articuloCodigo, String sucursalCodigo) {
        this.articuloSalaPK = new ArticuloSalaPK(articuloCodigo, sucursalCodigo);
    }

    public ArticuloSalaPK getArticuloSalaPK() {
        return articuloSalaPK;
    }

    public void setArticuloSalaPK(ArticuloSalaPK articuloSalaPK) {
        this.articuloSalaPK = articuloSalaPK;
    }

    public Long getArticuloExistenciaFisica() {
        return articuloExistenciaFisica;
    }

    public void setArticuloExistenciaFisica(Long articuloExistenciaFisica) {
        this.articuloExistenciaFisica = articuloExistenciaFisica;
    }

    public Long getArticuloExistenciaActual() {
        return articuloExistenciaActual;
    }

    public void setArticuloExistenciaActual(Long articuloExistenciaActual) {
        this.articuloExistenciaActual = articuloExistenciaActual;
    }

    public Long getArticuloExistenciaAnterior() {
        return articuloExistenciaAnterior;
    }

    public void setArticuloExistenciaAnterior(Long articuloExistenciaAnterior) {
        this.articuloExistenciaAnterior = articuloExistenciaAnterior;
    }

    public Articulo getArticulo() {
        return articulo;
    }

    public void setArticulo(Articulo articulo) {
        this.articulo = articulo;
    }

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

    @Override
    public String toString() {
        return "com.cosmodas.dbcon.ArticuloSala[ articuloSalaPK=" + articuloSalaPK + " ]";
    }

}
