Estou realizando um update em um objeto e ocorre este erro abaixo :
org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
o meu código :
public String salvar(){
try {
if (!(this.idprojetopai == (long)0)) {
this.projeto.setProjetopai(new Projeto(this.idprojetopai));
} else {
this.projeto.getProjetopai().setIdprojeto(null);
}
if (this.projeto.getIdprojeto() == (long)0) {
gerente.save(this.projeto);
} else {
gerente.update(this.projeto);
}
msg.addSuccessMessage("PROJETO cadastrado com sucesso");
} catch (Exception ex) {
ex.printStackTrace();
msg.addErrorMessage("Não foi possÃvel atualizar o registro!");
}
if (projeto.getIdprojeto() ==(long)0){
projeto = new Projeto();
}
return null;
}
[/b]
