/* * 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 javax.persistence.Basic; import javax.persistence.Column; import javax.persistence.Embeddable; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; /** * * @author Junior Cabal */ @Embeddable public class ProgramaPK implements Serializable { @Basic(optional = false) @NotNull @Size(min = 1, max = 6) @Column(name = "codigo") private String codigo; @Basic(optional = false) @NotNull @Size(min = 1, max = 4) @Column(name = "version") private String version; public ProgramaPK() { } public ProgramaPK(String codigo, String version) { this.codigo = codigo; this.version = version; } public String getCodigo() { return codigo; } public void setCodigo(String codigo) { this.codigo = codigo; } public String getVersion() { return version; } public void setVersion(String version) { this.version = version; } @Override public int hashCode() { int hash = 0; hash += (codigo != null ? codigo.hashCode() : 0); hash += (version != null ? version.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 ProgramaPK)) { return false; } ProgramaPK other = (ProgramaPK) object; if ((this.codigo == null && other.codigo != null) || (this.codigo != null && !this.codigo.equals(other.codigo))) { return false; } if ((this.version == null && other.version != null) || (this.version != null && !this.version.equals(other.version))) { return false; } return true; } @Override public String toString() { return "com.pepe.jpa.entities.ProgramaPK[ codigo=" + codigo + ", version=" + version + " ]"; } }