/*
* 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.pepe.jpa.entities;
import java.io.Serializable;
import java.util.List;
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;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Junior Cabal
*/
@Entity
@Table(name = "estado")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Estado.findAll", query = "SELECT e FROM Estado e"),
@NamedQuery(name = "Estado.findByIdEstado", query = "SELECT e FROM Estado e WHERE e.idEstado = :idEstado"),
@NamedQuery(name = "Estado.findByEstado", query = "SELECT e FROM Estado e WHERE e.estado = :estado")})
public class Estado implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id_estado")
private Integer idEstado;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 45)
@Column(name = "estado")
private String estado;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "idEstado")
private List<Desercion> desercionList;
public Estado() {
}
public Estado(Integer idEstado) {
this.idEstado = idEstado;
}
public Estado(Integer idEstado, String estado) {
this.idEstado = idEstado;
this.estado = estado;
}
public Integer getIdEstado() {
return idEstado;
}
public void setIdEstado(Integer idEstado) {
this.idEstado = idEstado;
}
public String getEstado() {
return estado;
}
public void setEstado(String estado) {
this.estado = estado;
}
@XmlTransient
public List<Desercion> getDesercionList() {
return desercionList;
}
public void setDesercionList(List<Desercion> desercionList) {
this.desercionList = desercionList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idEstado != null ? idEstado.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 Estado)) {
return false;
}
Estado other = (Estado) object;
if ((this.idEstado == null && other.idEstado != null) || (this.idEstado != null && !this.idEstado.equals(other.idEstado))) {
return false;
}
return true;
}
@Override
public String toString() {
return estado;
}
}