Tenho uma Super classe pessoa e uma classe filha representante, preciso rescrever o metodo equals e está ocorrendo um erro.
Pessoa
@Entity
@Table(name="PESSOAS")
@Inheritance(strategy = TABLE_PER_CLASS)
@MappedSuperclass
public class Pessoa implements Serializable {
private static final long serialVersionUID = 5743696681667477943L;
private String codigo;
...
@Id
public String getCodigo() {
return codigo;
}
public void setCodigo(String codigo) {
this.codigo = codigo;
}
}
Pessoa Juridica
@MappedSuperclass
public abstract class PessoaJuridica extends Pessoa implements Serializable {
...
}
Representante
@Entity
@Table(name = "REPRESENTANTES")
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public class Representante extends PessoaJuridica {
.....
@Override
public boolean equals(Object obj) {
if(obj == null){
return false;
}
if (getCodigo().equals(((Representante) obj).getCodigo())) {
return true;
} else {
return false;
}
}
@Override
public int hashCode() {
return getCodigo().hashCode();
}
]
Erro :
11:00:27,187 ERROR [BasicPropertyAccessor] IllegalArgumentException in class: br.com.model.legado.cadastros.pessoa.Pessoa, getter method of property: codigo
11:00:27,212 SEVERE [application] javax.ejb.EJBException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of br.com.model.legado.cadastros.pessoa.Pessoa.codigo
javax.faces.el.EvaluationException: javax.ejb.EJBException: org.hibernate.PropertyAccessException: IllegalArgumentException occurred calling getter of br.com.model.legado.cadastros.pessoa.Pessoa.codigo