/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package mx.edu.um.mateo.colportor.model; import java.io.Serializable; import java.util.Objects; import javax.persistence.*; import org.hibernate.validator.constraints.NotBlank; /** * * @author gibrandemetrioo */ @Entity @Table(name = "ciudades") public class Ciudad implements Serializable{ @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Version private Integer version; @NotBlank @Column(length= 128) private String nombre; @ManyToOne private Estado estado; public Ciudad (){ } public Ciudad (Estado estado){ this.estado = estado; } public Ciudad (String nombre){ this.nombre = nombre; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getNombre() { return nombre; } public void setNombre(String nombre) { this.nombre = nombre; } public Integer getVersion() { return version; } public void setVersion(Integer version) { this.version = version; } public Estado getEstado() { return estado; } public void setEstado(Estado estado) { this.estado = estado; } @Override public boolean equals(Object obj) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final Ciudad other = (Ciudad) obj; if (!Objects.equals(this.nombre, other.nombre)) { return false; } return true; } @Override public int hashCode() { int hash = 7; hash = 73 * hash + Objects.hashCode(this.nombre); return hash; } @Override public String toString() { return "Ciudad{" + "nombre=" + nombre + '}'; } }