/**
   * Method to do deletes. This method is to be used during a transaction, otherwise use the
   * doDelete(Criteria) method. It will take care of the connection details internally.
   *
   * @param criteria object containing data that is used DELETE from database.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static void doDelete(Criteria criteria, Connection con) throws TorqueException {
    correctBooleans(criteria);

    setDbName(criteria);

    if (con == null) {
      BasePeer.doDelete(criteria);
    } else {
      BasePeer.doDelete(criteria, con);
    }
  }
  /**
   * Method to do inserts. This method is to be used during a transaction, otherwise use the
   * doInsert(Criteria) method. It will take care of the connection details internally.
   *
   * @param criteria object used to create the INSERT statement.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static ObjectKey doInsert(Criteria criteria, Connection con) throws TorqueException {
    correctBooleans(criteria);

    setDbName(criteria);

    if (con == null) {
      return BasePeer.doInsert(criteria);
    } else {
      return BasePeer.doInsert(criteria, con);
    }
  }
  /**
   * Method to do updates. This method is to be used during a transaction, otherwise use the
   * doUpdate(Criteria) method. It will take care of the connection details internally.
   *
   * @param criteria object containing data that is used to create the UPDATE statement.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static void doUpdate(Criteria criteria, Connection con) throws TorqueException {
    Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
    correctBooleans(criteria);

    selectCriteria.put(ID, criteria.remove(ID));

    setDbName(criteria);

    if (con == null) {
      BasePeer.doUpdate(selectCriteria, criteria);
    } else {
      BasePeer.doUpdate(selectCriteria, criteria, con);
    }
  }
  /**
   * Grabs the raw Village records to be formed into objects. This method should be used for
   * transactions
   *
   * @param criteria object used to create the SELECT statement.
   * @param con the connection to use
   * @throws TorqueException Any exceptions caught during processing will be rethrown wrapped into a
   *     TorqueException.
   */
  public static List doSelectVillageRecords(Criteria criteria, Connection con)
      throws TorqueException {
    if (criteria.getSelectColumns().size() == 0) {
      addSelectColumns(criteria);
    }
    correctBooleans(criteria);

    setDbName(criteria);

    // BasePeer returns a List of Value (Village) arrays.  The array
    // order follows the order columns were placed in the Select clause.
    if (con == null) {
      return BasePeer.doSelect(criteria);
    } else {
      return BasePeer.doSelect(criteria, con);
    }
  }
 /**
  * changes the boolean values in the criteria to the appropriate type, whenever a booleanchar or
  * booleanint column is involved. This enables the user to create criteria using Boolean values
  * for booleanchar or booleanint columns
  *
  * @param criteria the criteria in which the boolean values should be corrected
  * @throws TorqueException if the database map for the criteria cannot be obtained.
  */
 public static void correctBooleans(Criteria criteria) throws TorqueException {
   correctBooleans(criteria, getTableMap());
 }