// Verify the transaction is active
if (!tx.isActive()) {
throw new JDOUserException("DeletePersistent " +
"must be called in an active transaction");
}
StateItf sa = null;
try {
if (!sp.jdoIsPersistent()) {
throw new JDOUserException(
"DeletePersistent on an instance non persistent.");
}
if (sp.jdoIsDeleted()) {
return;
}
sp.speedoGetHome().sendEvent(HomeItf.PRE_REMOVE, sp, null);
sa = (StateItf) tpm.unexport(tx, sp);
sp.speedoGetHome().sendEvent(HomeItf.POST_REMOVE, sp, null);
} catch (RolledBackPersistenceException e) {
throw ((JDOTransactionItf) tx).rollBackOnInternalError(e);
} catch (PersistenceException e) {
throw new JDOException("", ExceptionHelper.getNested(e));
}
//remove the multivalued fields and cascade delete
sa.deletePersistent(this);
if (logger.isLoggable(BasicLevel.DEBUG)) {
logger.log(BasicLevel.DEBUG,
"Delete a persistent instance, identifier=" + sp.getPName());
}
}