Package org.apache.ibatis.session

Examples of org.apache.ibatis.session.RowBounds


    SqlSession session = myBatis.openSession(false);
    try {
      Map<String, Object> params = newHashMap();
      params.put(QUERY_PARAMETER, query);
      params.put(TEMPLATE_ID_PARAMETER, templateId);
      return session.selectList("org.sonar.core.permission.PermissionTemplateMapper.selectUsers", params, new RowBounds(offset, limit));
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here


    SqlSession session = myBatis.openSession(false);
    try {
      Map<String, Object> params = newHashMap();
      params.put(QUERY_PARAMETER, query);
      params.put(COMPONENT_ID_PARAMETER, componentId);
      return session.selectList("org.sonar.core.permission.PermissionMapper.selectUsers", params, new RowBounds(offset, limit));
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  public List<ProjectQgateAssociationDto> selectProjects(ProjectQgateAssociationQuery query, Long gateId, int offset, int limit) {
    SqlSession session = mybatis.openSession(false);
    try {
      Map<String, Object> params = ImmutableMap.of("query", query, "gateId", gateId.toString());
      return session.selectList("org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper.selectProjects", params, new RowBounds(offset, limit));
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
View Full Code Here

  public Object intercept(final Invocation invocation) throws Throwable {
        final Executor executor = (Executor) invocation.getTarget();
        final Object[] queryArgs = invocation.getArgs();
        final MappedStatement ms = (MappedStatement)queryArgs[MAPPED_STATEMENT_INDEX];
        final Object parameter = queryArgs[PARAMETER_INDEX];
        final RowBounds rowBounds = (RowBounds)queryArgs[ROWBOUNDS_INDEX];
        final PageBounds pageBounds = new PageBounds(rowBounds);

        if(pageBounds.getOffset() == RowBounds.NO_ROW_OFFSET
                && pageBounds.getLimit() == RowBounds.NO_ROW_LIMIT
                && pageBounds.getOrders().isEmpty()){
            return invocation.proceed();
        }

        final Dialect dialect;
        try {
            Class clazz = Class.forName(dialectClass);
            Constructor constructor = clazz.getConstructor(MappedStatement.class, Object.class, PageBounds.class);
            dialect = (Dialect)constructor.newInstance(new Object[]{ms, parameter, pageBounds});
        } catch (Exception e) {
            throw new ClassNotFoundException("Cannot create dialect instance: "+dialectClass,e);
        }

        final BoundSql boundSql = ms.getBoundSql(parameter);

        queryArgs[MAPPED_STATEMENT_INDEX] = copyFromNewSql(ms,boundSql,dialect.getPageSQL(), dialect.getParameterMappings(), dialect.getParameterObject());
        queryArgs[PARAMETER_INDEX] = dialect.getParameterObject();
        queryArgs[ROWBOUNDS_INDEX] = new RowBounds(RowBounds.NO_ROW_OFFSET,RowBounds.NO_ROW_LIMIT);

        Boolean async = pageBounds.getAsyncTotalCount() == null ? asyncTotalCount : pageBounds.getAsyncTotalCount();
        Future<List> listFuture = call(new Callable<List>() {
            public List call() throws Exception {
                return (List)invocation.proceed();
View Full Code Here

    public List<M> selectList(String selectId, Object parameter) {
        return getSqlSession().selectList(NAMESPACE.concat(selectId), parameter);
    }

    public List<M> selectLimitedList(String selectId, int limit, Object parameter) {
        RowBounds rowBounds = new RowBounds(0, limit);
        return getSqlSession().selectList(NAMESPACE.concat(selectId), parameter);
    }
View Full Code Here

            String countId = selectId.concat("Count");
            long totalCount = selectPageCount(countId, model);
            page.setTotalCount(totalCount);
        }
        //
        RowBounds rowBounds = new RowBounds(page.getFirst() - 1, page.getPageSize());
        List<M> results = getSqlSession().selectList(NAMESPACE.concat(selectId), model, rowBounds);
        //
        return page.setResults(results);
    }
View Full Code Here

    TablePage tablePage = new TablePage();

    @SuppressWarnings("rawtypes")
    List tableData = getDbSqlSession().getSqlSession()
      .selectList("selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults));

    tablePage.setTableName(tablePageQuery.getTableName());
    tablePage.setTotal(getTableCount(tablePageQuery.getTableName()));
    tablePage.setRows((List<Map<String,Object>>)tableData);
    tablePage.setFirstResult(firstResult);
View Full Code Here

    TablePage tablePage = new TablePage();

    @SuppressWarnings("rawtypes")
    List tableData = getDbSqlSession().getSqlSession()
      .selectList("selectTableData", tablePageQuery, new RowBounds(firstResult, maxResults));

    tablePage.setTableName(tablePageQuery.getTableName());
    tablePage.setTotal(getTableCount(tablePageQuery.getTableName()));
    tablePage.setRows((List<Map<String,Object>>)tableData);
    tablePage.setFirstResult(firstResult);
View Full Code Here

            PkfieldsExample example = new PkfieldsExample();
            example.createCriteria().andId2Between(1, 3);

            example.setOrderByClause("ID1, ID2");
            RowBounds rb = new RowBounds(2, 3);
            List<Pkfields> answer = mapper.selectByExampleWithRowbounds(example, rb);
            assertEquals(3, answer.size());
            assertEquals("Pebbles", answer.get(0).getFirstname());
            assertEquals("Barney", answer.get(1).getFirstname());
            assertEquals("Betty", answer.get(2).getFirstname());
View Full Code Here

                //分页查询 本地化对象 修改数据库注意修改实现
                String pageSql = SQLHelper.generatePageSql(originalSql, page, DIALECT);
//                if (log.isDebugEnabled()) {
//                    log.debug("PAGE SQL:" + StringUtils.replace(pageSql, "\n", ""));
//                }
                invocation.getArgs()[2] = new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
                BoundSql newBoundSql = new BoundSql(mappedStatement.getConfiguration(), pageSql, boundSql.getParameterMappings(), boundSql.getParameterObject());
                MappedStatement newMs = copyFromMappedStatement(mappedStatement, new BoundSqlSqlSource(newBoundSql));

                invocation.getArgs()[0] = newMs;
            }
View Full Code Here

TOP

Related Classes of org.apache.ibatis.session.RowBounds

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.