Pessoal
Estou tentando deletar um registro da minha tabela e quando eu chamo a função delete do hibernate, ele gera uma exception assim
So que quando eu tento salvar ou consultar os dados, eu obtenho tudo certo !!! So estou tendo problemas mesmo com o delete !
Alguem tem alguma sugestao ??
Meu bean esta asism
@Entity
@Table(name = "comentario", schema = "blog")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Comentario extends ActionForm implements Serializable {
public Comentario() {
this.comentario = null;
this.nome = null;
this.email = null;
this.id = 0;
// this.index = 0;
this.date = null;
this.radio = "";
}
@Id
@Column(name = "id")
private int id;
@OneToMany
private String comentario;
private int index;
private String nome;
private String email;
@Column(name = "dataCadastro")
@Temporal(TemporalType.TIMESTAMP)
private Date date;
Com os respectivos getter e setter.
Agora como eu estou chamando o metodo delete, é assim.
Session session = HibernateUtil.session();
Transaction transaction = session.beginTransaction();
int id = bean.getId(); //id = 16
try {
session.delete(id);
transaction.commit();
session.close();
} catch (Exception e) {
System.out.println("Erro na remoção do objeto. " + e.getMessage());
log.error("Erro na remoção do objeto: " + e.getMessage());
throw e;
}
O que pode estar errado ??
Obrigado pela ajuda
Abs