Example usage for org.apache.ibatis.session RowBounds RowBounds

List of usage examples for org.apache.ibatis.session RowBounds RowBounds

Introduction

In this page you can find the example usage for org.apache.ibatis.session RowBounds RowBounds.

Prototype

public RowBounds(int offset, int limit) 

Source Link

Usage

From source file:com.glaf.core.service.impl.MxSysLogServiceImpl.java

License:Apache License

public List<SysLog> getSysLogsByQueryCriteria(int start, int pageSize, SysLogQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<SysLog> rows = sqlSessionTemplate.selectList("getSysLogs", query, rowBounds);
    return rows;/*from   www . j a  v  a 2  s .c  om*/
}

From source file:com.glaf.core.service.impl.MxSysSchedulerServiceImpl.java

License:Apache License

/**
 * ????/*from  w w w. jav  a  2 s  . co  m*/
 * 
 * @return
 */
public List<Scheduler> getSchedulersByQueryCriteria(int start, int pageSize, SchedulerQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<Scheduler> rows = sqlSessionTemplate.selectList("getSchedulers", query, rowBounds);
    return rows;
}

From source file:com.glaf.core.service.impl.MxSystemParamServiceImpl.java

License:Apache License

/**
 * ????// w ww. j  av a2 s  .co m
 * 
 * @return
 */
public List<SystemParam> getSystemParamsByQueryCriteria(int start, int pageSize, SystemParamQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<SystemParam> rows = sqlSession.selectList("getSystemParamsByQueryCriteria", query, rowBounds);
    return rows;
}

From source file:com.glaf.core.service.impl.MxTableDefinitionServiceImpl.java

License:Apache License

/**
 * ????//w  w  w  . j  a v a 2 s .c  o m
 * 
 * @return
 */
public List<TableDefinition> getTableDefinitionsByQueryCriteria(int start, int pageSize,
        TableDefinitionQuery query) {
    if (StringUtils.isEmpty(query.getType())) {
        throw new RuntimeException(" type is null ");
    }
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<TableDefinition> rows = sqlSession.selectList("getTableDefinitions", query, rowBounds);
    return rows;
}

From source file:com.glaf.core.service.impl.MxTablePageServiceImpl.java

License:Apache License

public List<Map<String, Object>> getListData(String sql, Map<String, Object> params, int begin, int limit) {
    if (!DBUtils.isLegalQuerySql(sql)) {
        throw new RuntimeException(" SQL statement illegal ");
    }/*from   ww w  .  jav  a  2s  . c o m*/
    Map<String, Object> queryMap = new HashMap<String, Object>();
    if (params != null && !params.isEmpty()) {
        queryMap.putAll(params);
    }
    queryMap.put("queryString", sql);
    RowBounds rowBounds = new RowBounds(begin, limit);
    List<Map<String, Object>> dataList = sqlSession.selectList("getSqlQueryList", queryMap, rowBounds);
    return dataList;
}

From source file:com.glaf.core.service.impl.MxTablePageServiceImpl.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Object> getQueryList(String querySql, int begin, int pageSize, List<QueryCondition> conditions) {
    if (!DBUtils.isLegalQuerySql(querySql)) {
        throw new RuntimeException(" SQL statement illegal ");
    }//from  w ww  . j  av  a  2  s  .  c  o  m
    SqlExecutor sqlExecutor = QueryUtils.getMyBatisAndConditionSql(conditions);

    StringBuilder buffer = new StringBuilder();
    buffer.append(querySql);
    if (querySql.toUpperCase().indexOf(" WHERE ") == -1) {
        buffer.append(" WHERE 1=1 ");
    }
    String sql = buffer.toString() + sqlExecutor.getSql();

    Map<String, Object> params = new java.util.HashMap<String, Object>();
    if (sqlExecutor.getParameter() instanceof Map) {
        params.putAll((Map) sqlExecutor.getParameter());
    }

    logger.debug("sql:\n" + sql);
    logger.debug("params:" + params);

    params.put("queryString", sql);

    if (begin < 0) {
        begin = 0;
    }
    if (pageSize <= 0) {
        pageSize = Paging.DEFAULT_PAGE_SIZE;
    }
    RowBounds rowBounds = new RowBounds(begin, pageSize);
    List<Object> rows = sqlSession.selectList("getSqlQueryList", params, rowBounds);
    return rows;
}

From source file:com.glaf.core.service.impl.MxTablePageServiceImpl.java

License:Apache License

public List<Map<String, Object>> getTableData(String tableName, int firstResult, int maxResults) {
    TablePageQuery query = new TablePageQuery();
    query.tableName(tableName);/*from  www .j a  va 2 s. c  o  m*/
    int begin = query.getFirstResult();
    int pageSize = query.getMaxResults();
    if (begin < 0) {
        begin = 0;
    }
    if (pageSize <= 0) {
        pageSize = Paging.DEFAULT_PAGE_SIZE;
    }
    RowBounds rowBounds = new RowBounds(begin, pageSize);
    List<Map<String, Object>> rows = sqlSession.selectList("getTableData", query, rowBounds);
    return rows;
}

From source file:com.glaf.core.service.impl.MxTablePageServiceImpl.java

License:Apache License

@Transactional(readOnly = true)
public List<Map<String, Object>> getTableData(TablePageQuery query) {
    int begin = query.getFirstResult();
    int pageSize = query.getMaxResults();
    if (begin < 0) {
        begin = 0;//from   w w w .j a  va2 s .c  o  m
    }
    if (pageSize <= 0) {
        pageSize = Paging.DEFAULT_PAGE_SIZE;
    }
    RowBounds rowBounds = new RowBounds(begin, pageSize);
    List<Map<String, Object>> list = sqlSession.selectList("getTableData", query, rowBounds);
    return list;
}

From source file:com.glaf.core.service.impl.MxTablePageServiceImpl.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Object> getTableList(String tableName, String idColumn, int begin, int pageSize,
        List<QueryCondition> conditions) {
    SqlExecutor sqlExecutor = QueryUtils.getMyBatisAndConditionSql(conditions);

    StringBuilder buffer = new StringBuilder();
    buffer.append(" select * ").append(" from ").append(tableName);
    buffer.append(" where 1=1 ");
    String sql = buffer.toString() + sqlExecutor.getSql();

    Map<String, Object> params = new java.util.HashMap<String, Object>();
    if (sqlExecutor.getParameter() instanceof Map) {
        params.putAll((Map) sqlExecutor.getParameter());
    }/*w  w  w .  j  av  a2 s  .  c o  m*/

    logger.debug("sql:\n" + sql);
    logger.debug("params:" + params);

    params.put("queryString", sql);

    if (begin < 0) {
        begin = 0;
    }
    if (pageSize <= 0) {
        pageSize = Paging.DEFAULT_PAGE_SIZE;
    }
    RowBounds rowBounds = new RowBounds(begin, pageSize);
    List<Object> rows = sqlSession.selectList("getSqlQueryList", params, rowBounds);
    return rows;
}

From source file:com.glaf.core.service.impl.MxTablePageServiceImpl.java

License:Apache License

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Object> getTableList(String tableName, String idColumn, Map<String, String> selectColumns,
        int begin, int pageSize, List<QueryCondition> conditions) {
    SqlExecutor sqlExecutor = QueryUtils.getMyBatisAndConditionSql(conditions);
    StringBuilder buffer = new StringBuilder();
    buffer.append(" select ");
    if (selectColumns != null && !selectColumns.isEmpty()) {
        Set<Entry<String, String>> entrySet = selectColumns.entrySet();
        for (Entry<String, String> entry : entrySet) {
            String columnName = entry.getKey();
            String columnLabel = entry.getValue();
            if (columnName != null && columnLabel != null) {
                buffer.append(columnName).append(" as ").append(columnLabel);
                buffer.append(" , ");
            }/* w w w.ja v a  2  s .  c om*/
        }
        buffer.delete(buffer.length() - 2, buffer.length());
        buffer.append(" from ").append(tableName);
    } else {
        buffer.append(" * from ").append(tableName);
    }

    buffer.append(" where 1=1 ");

    String sql = buffer.toString() + sqlExecutor.getSql();
    Map<String, Object> params = new java.util.HashMap<String, Object>();
    if (sqlExecutor.getParameter() instanceof Map) {
        params.putAll((Map) sqlExecutor.getParameter());
    }

    logger.debug("sql:\n" + sql);
    logger.debug("params:" + params);

    params.put("queryString", sql);

    if (begin < 0) {
        begin = 0;
    }
    if (pageSize <= 0) {
        pageSize = Paging.DEFAULT_PAGE_SIZE;
    }
    RowBounds rowBounds = new RowBounds(begin, pageSize);
    List<Object> rows = sqlSession.selectList("getSqlQueryList", params, rowBounds);
    return rows;
}