ClassDescriptor descriptor = this.descriptor;
DescriptorEventManager eventManager = descriptor.getEventManager();
// PERF: Avoid events if no listeners.
if (eventManager.hasAnyEventListeners()) {
// Need to run pre-delete selector if available
eventManager.executeEvent(new DescriptorEvent(DescriptorEventManager.PreDeleteEvent, this));
}
// Verify if deep shallow modify is turned on
if (shouldCascadeParts()) {
descriptor.getQueryManager().preDelete(this);
}
// CR#2660080 missing aboutToDelete event.
// PERF: Avoid events if no listeners.
if (eventManager.hasAnyEventListeners()) {
DescriptorEvent event = new DescriptorEvent(DescriptorEventManager.AboutToDeleteEvent, this);
event.setRecord(getModifyRow());
eventManager.executeEvent(event);
}
if (QueryMonitor.shouldMonitor()) {
QueryMonitor.incrementDelete(this);
}
int rowCount = getQueryMechanism().deleteObject().intValue();
if (rowCount < 1) {
if (session.hasEventManager()) {
session.getEventManager().noRowsModified(this, object);
}
}
if (descriptor.usesOptimisticLocking()) {
descriptor.getOptimisticLockingPolicy().validateDelete(rowCount, object, this);
}
commitManager.markPostModifyCommitInProgress(getObject());
// Verify if deep shallow modify is turned on
if (shouldCascadeParts()) {
descriptor.getQueryManager().postDelete(this);
}
if ((descriptor.getHistoryPolicy() != null) && descriptor.getHistoryPolicy().shouldHandleWrites()) {
descriptor.getHistoryPolicy().postDelete(this);
}
// PERF: Avoid events if no listeners.
if (eventManager.hasAnyEventListeners()) {
// Need to run post-delete selector if available
eventManager.executeEvent(new DescriptorEvent(DescriptorEventManager.PostDeleteEvent, this));
}
if (!isUnitOfWork) {
session.commitTransaction();
}