/*
 * 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.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author obper
 */
@Entity
@Table(name = "regalo")
@XmlRootElement
@NamedQueries({
        @NamedQuery(name = "Regalo.findAll", query = "SELECT r FROM Regalo r"),
        @NamedQuery(name = "Regalo.findByProducto", query = "SELECT r FROM Regalo r WHERE r.producto = :producto"),
        @NamedQuery(name = "Regalo.findBySucursal", query = "SELECT r FROM Regalo r WHERE r.sucursal = :sucursal"),
        @NamedQuery(name = "Regalo.findById", query = "SELECT r FROM Regalo r WHERE r.id = :id")})
public class Regalo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Size(max = 5)
    @Column(name = "producto")
    private String producto;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2)
    @Column(name = "sucursal")
    private String sucursal;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;

    public Regalo() {
    }

    public Regalo(Integer id) {
        this.id = id;
    }

    public Regalo(Integer id, String sucursal) {
        this.id = id;
        this.sucursal = sucursal;
    }

    public String getProducto() {
        return producto;
    }

    public void setProducto(String producto) {
        this.producto = producto;
    }

    public String getSucursal() {
        return sucursal;
    }

    public void setSucursal(String sucursal) {
        this.sucursal = sucursal;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

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

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

}
