/**
   * delete all of the objects as a single transaction. This should delete the object in the correct
   * order to maintain referential integrity.
   */
  public void deleteAllObjects(List objects)
      throws RuntimeException, DatabaseException, OptimisticLockException {
    this.isActive = true;
    AbstractSession session = getSession();
    session.beginTransaction();

    try {
      // PERF: Optimize single object case.
      if (objects.size() == 1) {
        deleteAllObjects(objects.get(0).getClass(), objects, session);
      } else {
        List commitOrder = getCommitOrder();
        for (int orderIndex = commitOrder.size() - 1; orderIndex >= 0; orderIndex--) {
          Class theClass = (Class) commitOrder.get(orderIndex);
          deleteAllObjects(theClass, objects, session);
        }
      }

      session.commitTransaction();
    } catch (RuntimeException exception) {
      try {
        session.rollbackTransaction();
      } catch (Exception ignore) {
      }
      throw exception;
    } finally {
      reinitialize();
      this.isActive = false;
    }
  }
 /**
  * INTERNAL: Commit the transaction on all child sessions. This assumes that the commit of the
  * transaction will not fail because all of the modification has already taken place and no errors
  * would have occurred.
  */
 protected void basicCommitTransaction() throws DatabaseException {
   // Do one last check it make sure that all sessions are still connected.
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     if (!session.isConnected()) {
       throw DatabaseException.databaseAccessorNotConnected();
     }
   }
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     session.commitTransaction();
   }
 }