/*
 * 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.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 = "COOKMETHOD")
@NamedQueries({@NamedQuery(name = "CookMethod.findAll", query = "SELECT c FROM CookMethod c"), @NamedQuery(name = "CookMethod.findByCookmethodid", query = "SELECT c FROM CookMethod c WHERE c.cookmethodid = :cookmethodid"), @NamedQuery(name = "CookMethod.findByName", query = "SELECT c FROM CookMethod c WHERE c.name = :name")})
public class CookMethod implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "COOKMETHODID")
    private Integer cookmethodid;
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    @OneToMany(mappedBy = "cookmethod")
    private Collection<Recipe> recipeCollection;

    public CookMethod()
    {
    }

    public CookMethod(Integer cookmethodid)
    {
        this.cookmethodid = cookmethodid;
    }

    public CookMethod(Integer cookmethodid, String name)
    {
        this.cookmethodid = cookmethodid;
        this.name = name;
    }

    public Integer getCookmethodid()
    {
        return cookmethodid;
    }

    public void setCookmethodid(Integer cookmethodid)
    {
        this.cookmethodid = cookmethodid;
    }

    public String getName()
    {
        return name;
    }

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

    public Collection<Recipe> getRecipeCollection()
    {
        return recipeCollection;
    }

    public void setRecipeCollection(Collection<Recipe> recipeCollection)
    {
        this.recipeCollection = recipeCollection;
    }

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

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

}
