⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqlmapdaotemplate.java

📁 本套系统采用了业界当前最为流行的beanAction组件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForObject - id ["
          + id + "], parameterObject [" + parameterObject + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects.
   * <p/>
   * The parameter object is generally used to supply the input
   * data for the WHERE clause parameter(s) of the SELECT statement.
   *
   * @param id              The name of the statement to execute.
   * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
   * @return A List of result objects.
   */
  public List queryForList(String id, Object parameterObject) {
    try {
      return getSqlMapExecutor().queryForList(id, parameterObject);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForList - id ["
          + id + "], parameterObject [" + parameterObject + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects.
   * <p/>
   * This overload assumes no parameter is needed.
   *
   * @param id              The name of the statement to execute.
   * @return A List of result objects.
   */
  public List queryForList(String id) {
    try {
      return getSqlMapExecutor().queryForList(id);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForList - id ["
          + id + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects within a certain range.
   * <p/>
   * The parameter object is generally used to supply the input
   * data for the WHERE clause parameter(s) of the SELECT statement.
   *
   * @param id              The name of the statement to execute.
   * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
   * @param skip            The number of results to ignore.
   * @param max             The maximum number of results to return.
   * @return A List of result objects.
   */
  public List queryForList(String id, Object parameterObject, int skip, int max) {
    try {
      return getSqlMapExecutor().queryForList(id, parameterObject, skip, max);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForList - id ["
          + id + "], parameterObject [" + parameterObject + "], skip ["
          + skip + "], max [" + max + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects within a certain range.
   * <p/>
   * This overload assumes no parameter is needed.
   *
   * @param id              The name of the statement to execute.
   * @param skip            The number of results to ignore.
   * @param max             The maximum number of results to return.
   * @return A List of result objects.
   */
  public List queryForList(String id, int skip, int max) {
    try {
      return getSqlMapExecutor().queryForList(id, skip, max);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForList - id ["
          + id + "], skip ["
          + skip + "], max [" + max + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects that will be handled one at a time by a
   * RowHandler.
   * <p/>
   * This is generally a good approach to take when dealing with large sets
   * of records (i.e. hundreds, thousands...) that need to be processed without
   * eating up all of the system resources.
   * <p/>
   * The parameter object is generally used to supply the input
   * data for the WHERE clause parameter(s) of the SELECT statement.
   *
   * @param id              The name of the statement to execute.
   * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
   * @param rowHandler      A RowHandler instance
   */
  public void queryWithRowHandler(String id, Object parameterObject, RowHandler rowHandler) {
    try {
      getSqlMapExecutor().queryWithRowHandler(id, parameterObject, rowHandler);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForList - id [" + id + "], parameterObject ["
          + parameterObject + "], rowHandler [ " + rowHandler + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects that will be handled one at a time by a
   * RowHandler.
   * <p/>
   * This is generally a good approach to take when dealing with large sets
   * of records (i.e. hundreds, thousands...) that need to be processed without
   * eating up all of the system resources.
   * <p/>
   * This overload assumes no parameter is needed.
   *
   * @param id              The name of the statement to execute.
   * @param rowHandler      A RowHandler instance
   */
  public void queryWithRowHandler(String id, RowHandler rowHandler) {
    try {
      getSqlMapExecutor().queryWithRowHandler(id, rowHandler);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForList - id [" + id + "], rowHandler [ "
          + rowHandler + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects a page at a time.
   * <p/>
   * The parameter object is generally used to supply the input
   * data for the WHERE clause parameter(s) of the SELECT statement.
   *
   * @param id              The name of the statement to execute.
   * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
   * @param pageSize        The maximum number of result objects each page can hold.
   * @return A PaginatedList of result objects.
   */
  public PaginatedList queryForPaginatedList(String id, Object parameterObject, int pageSize) {
    try {
      return getSqlMapExecutor().queryForPaginatedList(id, parameterObject, pageSize);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForPaginatedList - id [" + id + "], parameterObject ["
          + parameterObject + "], pageSize [" + pageSize + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects a page at a time.
   * <p/>
   * This overload assumes no parameter is needed.
   *
   * @param id              The name of the statement to execute.
   * @param pageSize        The maximum number of result objects each page can hold.
   * @return A PaginatedList of result objects.
   */
  public PaginatedList queryForPaginatedList(String id, int pageSize) {
    try {
      return getSqlMapExecutor().queryForPaginatedList(id, pageSize);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForPaginatedList - id [" + id + "], pageSize ["
          + pageSize + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects that will be keyed into a Map.
   * <p/>
   * The parameter object is generally used to supply the input
   * data for the WHERE clause parameter(s) of the SELECT statement.
   *
   * @param id              The name of the statement to execute.
   * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
   * @param keyProp         The property to be used as the key in the Map.
   * @return A Map keyed by keyProp with values being the result object instance.
   */
  public Map queryForMap(String id, Object parameterObject, String keyProp) {
    try {
      return getSqlMapExecutor().queryForMap(id, parameterObject, keyProp);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForMap - id [" + id + "], parameterObject ["
          + parameterObject + "], keyProp [" + keyProp + "].  Cause: " + e, e);
    }
  }

  /**
   * Executes a mapped SQL SELECT statement that returns data to populate
   * a number of result objects from which one property will be keyed into a Map.
   * <p/>
   * The parameter object is generally used to supply the input
   * data for the WHERE clause parameter(s) of the SELECT statement.
   *
   * @param id              The name of the statement to execute.
   * @param parameterObject The parameter object (e.g. JavaBean, Map, XML etc.).
   * @param keyProp         The property to be used as the key in the Map.
   * @param valueProp       The property to be used as the value in the Map.
   * @return A Map keyed by keyProp with values of valueProp.
   */
  public Map queryForMap(String id, Object parameterObject, String keyProp, String valueProp) {
    try {
      return getSqlMapExecutor().queryForMap(id, parameterObject, keyProp, valueProp);
    } catch (SQLException e) {
      throw new DaoException("Failed to queryForMap - id [" + id + "], parameterObject ["
          + parameterObject + "], keyProp [" + keyProp + "], valueProp ["
          + valueProp + "].  Cause: " + e, e);
    }
  }

  /**
   * Starts a batch in which update statements will be cached before being sent to
   * the database all at once. This can improve overall performance of updates update
   * when dealing with numerous updates (e.g. inserting 1:M related data).
   */
  public void startBatch() {
    try {
      getSqlMapExecutor().startBatch();
    } catch (SQLException e) {
      throw new DaoException("Failed to startBatch.  Cause: " + e, e);
    }
  }

  /**
   * Executes (flushes) all statements currently batched.
   */
  public int executeBatch() {
    try {
      return getSqlMapExecutor().executeBatch();
    } catch (SQLException e) {
      throw new DaoException("Failed to executeBatch.  Cause: " + e, e);
    }
  }

  /**
   * Executes (flushes) all statements currently batched.
   * 
   * @return a List of BatchResult objects.  There will be one element in the
   *  list for each sub-batch executed.  A sub-batch is created by adding a statement
   *  to the batch that does not equal the prior statement. 
   */
  public List executeBatchDetailed() {
    try {
      return getSqlMapExecutor().executeBatchDetailed();
    } catch (BatchException e) {
      throw new DaoException("Failed to executeBatch.  Cause: " + e, e);
    } catch (SQLException e) {
      throw new DaoException("Failed to executeBatch.  Cause: " + e, e);
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -