/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cookery_db.database;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
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.OneToMany;
import javax.persistence.Table;


/**
 *
 * @author nick
 */
@Entity
@Table(name = "QUANTITYUNIT")
@NamedQueries({@NamedQuery(name = "QuantityUnit.findAll", query = "SELECT q FROM QuantityUnit q"), @NamedQuery(name = "QuantityUnit.findByQuantityunitid", query = "SELECT q FROM QuantityUnit q WHERE q.quantityunitid = :quantityunitid"), @NamedQuery(name = "QuantityUnit.findByName", query = "SELECT q FROM QuantityUnit q WHERE q.name = :name"), @NamedQuery(name = "QuantityUnit.findByUnit", query = "SELECT q FROM QuantityUnit q WHERE q.unit = :unit")})
public class QuantityUnit implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "QUANTITYUNITID")
    private Integer quantityunitid;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @Basic(optional = false)
    @Column(name = "UNIT")
    private String unit;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "quantityunit")
    private Collection<RecipeIngredient> recipeIngredientCollection;

    public QuantityUnit()
    {
    }

    public QuantityUnit(Integer quantityunitid)
    {
        this.quantityunitid = quantityunitid;
    }

    public QuantityUnit(Integer quantityunitid, String name, String unit)
    {
        this.quantityunitid = quantityunitid;
        this.name = name;
        this.unit = unit;
    }

    public Integer getQuantityunitid()
    {
        return quantityunitid;
    }

    public void setQuantityunitid(Integer quantityunitid)
    {
        this.quantityunitid = quantityunitid;
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getUnit()
    {
        return unit;
    }

    public void setUnit(String unit)
    {
        this.unit = unit;
    }

    public Collection<RecipeIngredient> getRecipeIngredientCollection()
    {
        return recipeIngredientCollection;
    }

    public void setRecipeIngredientCollection(Collection<RecipeIngredient> recipeIngredientCollection)
    {
        this.recipeIngredientCollection = recipeIngredientCollection;
    }

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

    @Override
    public String toString()
    {
        return "cookery_db.database.QuantityUnit[quantityunitid=" + quantityunitid + "]";
    }

}
