/**
   * 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: Rollback the transaction on all child sessions. */
 protected void basicRollbackTransaction() throws DatabaseException {
   DatabaseException globalException = null;
   for (Iterator sessionEnum = getSessionsByName().values().iterator(); sessionEnum.hasNext(); ) {
     AbstractSession session = (AbstractSession) sessionEnum.next();
     try {
       session.rollbackTransaction();
     } catch (DatabaseException exception) {
       globalException = exception;
     }
   }
   if (globalException != null) {
     throw globalException;
   }
 }