Olá Senhores,
Gostaria de saber se algum dos senhores pode me dizer o porque desde método está disparando RollBackException
public void excluir(T object) {
EntityTransaction et = getEntityManager().getTransaction();
try {
et.begin();
object = getEntityManager().merge(object);
getEntityManager().remove(object);
et.commit();
} catch (DatabaseException dex) {
System.out.println("DataBaseException: " + dex.getMessage());
throw dex;
} catch (TopLinkException tex) {
System.out.println("TopLinkException: " + tex.getMessage());
throw tex;
} catch (RollbackException rollex) {
System.out.println("TopLinkException: " + rollex.getMessage());
try {
et.rollback();
} catch (Exception ex) {
ex.printStackTrace();
}
throw rollex;
}
}
A mensagem da exceção é: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot delete or update a parent row
Tentei todo tipo de tratamento de exceção ate descobrir que era uma rollbackexception, que não tem nada haver com a mensagem, entao coloquei no catch e se eu tentar executar um et.rollback(); me retorna a mensagem: java.lang.IllegalStateException: Exception Description: No transaction is currently active.
Ou Seja, por que essa exceção RollBackException, se não existe se quer a transação ativa? alguem sabe o motivo?