@Override
 public void removeReference(ObjectReference ref) {
   if (_newReferences.referenceForId(ref.getID()) != null) {
     _newReferences.removeReference(ref);
     referenceCountChanged(-1);
   }
   if (_committedReferences.referenceForId(ref.getID()) != null) {
     _committedReferences.removeReference(ref);
     referenceCountChanged(-1);
   }
 }
  public final boolean delete4(
      Transaction transaction, ObjectReference ref, Object obj, int cascade, boolean userCall) {
    int id = ref.getID();
    StatefulBuffer reader = readStatefulBufferById(transaction, id);
    if (reader != null) {
      if (obj != null) {
        if ((!showInternalClasses()) && Const4.CLASS_INTERNAL.isAssignableFrom(obj.getClass())) {
          return false;
        }
      }
      reader.setCascadeDeletes(cascade);
      transaction.idSystem().notifySlotDeleted(id, SlotChangeFactory.USER_OBJECTS);
      ClassMetadata classMetadata = ref.classMetadata();
      classMetadata.delete(reader, obj);

      return true;
    }
    return false;
  }