Package com.iisigroup.cap.jdbc.support

Examples of com.iisigroup.cap.jdbc.support.CapSqlSearchQueryProvider


      return sqlp.getValue(sqlId, sqlId);
    }
  }

  public Page<Map<String, Object>> queryForPage(String sqlId, ISearch search) {
    CapSqlSearchQueryProvider provider = new CapSqlSearchQueryProvider(
        search);
    String _sql = sqlp.getValue(sqlId, sqlId);
    StringBuffer sourceSql = new StringBuffer(_sql).append(
        _sql.toUpperCase().lastIndexOf("WHERE") > 0 ? " AND "
            : " WHERE ").append(provider.generateWhereCause());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(CapJdbcContants.SQLPaging_SourceSQL, sourceSql.toString());
    // 準備查詢筆數sql
    StringBuffer sql = new StringBuffer().append(CapDbUtil.spelParser(
        (String) sqltemp.getValue(CapJdbcContants.SQLPaging_TotalPage),
        params, sqlp.getParserContext()));
    sql.append(' ').append(
        sqltemp.getValue(CapJdbcContants.SQLQuery_Suffix, ""));
    if (logger.isTraceEnabled()) {
      logger.trace(new StringBuffer("\n\t").append(
          CapDbUtil.convertToSQLCommand(sql.toString(),
              provider.getParams())).toString());
    }
    String sqlRow = sql.toString();
    // 準備查詢list sql
    sourceSql.append(provider.generateOrderCause());
    params.put(CapJdbcContants.SQLPaging_SourceSQL, sourceSql.toString());
    sql = new StringBuffer().append(CapDbUtil.spelParser(
        (String) sqltemp.getValue(CapJdbcContants.SQLPaging_Query),
        params, sqlp.getParserContext()));
    sql.append(' ').append(
        sqltemp.getValue(CapJdbcContants.SQLQuery_Suffix, ""));
    if (logger.isTraceEnabled()) {
      logger.trace(new StringBuffer("\n\t").append(
          CapDbUtil.convertToSQLCommand(sql.toString(),
              provider.getParams())).toString());
    }
    long cur = System.currentTimeMillis();
    try {
      int totalRows = super.queryForInt(sqlRow, provider.getParams());
      List<Map<String, Object>> list = super.queryForList(
          sql.toString(), provider.getParams());
      return new Page<Map<String, Object>>(list, totalRows,
          search.getMaxResults(), search.getFirstResult());
    } catch (Exception e) {
      throw new CapDBException(e, causeClass);
    } finally {
View Full Code Here


    }
  }// ;

  public <T> Page<T> queryForPage(String sqlId, ISearch search,
      RowMapper<T> rm) {
    CapSqlSearchQueryProvider provider = new CapSqlSearchQueryProvider(
        search);
    String _sql = sqlp.getValue(sqlId, sqlId);
    StringBuffer sourceSql = new StringBuffer(_sql).append(
        _sql.toUpperCase().lastIndexOf("WHERE") > 0 ? " AND "
            : " WHERE ").append(provider.generateWhereCause());
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(CapJdbcContants.SQLPaging_SourceSQL, sourceSql.toString());
    // 準備查詢筆數sql
    StringBuffer sql = new StringBuffer().append(CapDbUtil.spelParser(
        (String) sqltemp.getValue(CapJdbcContants.SQLPaging_TotalPage),
        params, sqlp.getParserContext()));
    sql.append(' ').append(
        sqltemp.getValue(CapJdbcContants.SQLQuery_Suffix, ""));
    if (logger.isTraceEnabled()) {
      logger.trace(new StringBuffer("\n\t").append(
          CapDbUtil.convertToSQLCommand(sql.toString(),
              provider.getParams())).toString());
    }
    String sqlRow = sql.toString();
    // 準備查詢list sql
    sourceSql.append(provider.generateOrderCause());
    params.put(CapJdbcContants.SQLPaging_SourceSQL, sourceSql.toString());
    sql = new StringBuffer().append(CapDbUtil.spelParser(
        (String) sqltemp.getValue(CapJdbcContants.SQLPaging_Query),
        params, sqlp.getParserContext()));
    sql.append(' ').append(
        sqltemp.getValue(CapJdbcContants.SQLQuery_Suffix, ""));
    if (logger.isTraceEnabled()) {
      logger.trace(new StringBuffer("\n\t").append(
          CapDbUtil.convertToSQLCommand(sql.toString(),
              provider.getParams())).toString());
    }
    long cur = System.currentTimeMillis();
    try {
      int totalRows = super.queryForInt(sqlRow, provider.getParams());
      List<T> list = super.query(sql.toString(),
          provider.getParams(), rm);
      return new Page<T>(list, totalRows, search.getMaxResults(),
          search.getFirstResult());
    } catch (Exception e) {
      throw new CapDBException(e, causeClass);
    } finally {
View Full Code Here

TOP

Related Classes of com.iisigroup.cap.jdbc.support.CapSqlSearchQueryProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.