Package org.apache.ibatis.session

Examples of org.apache.ibatis.session.RowBounds


  @Test
  public void shouldSelectListOfPostsLike() {
    SqlSession session = sqlSessionFactory.openSession();
    try {
      BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
      List<Post> posts = mapper.selectPostsLike(new RowBounds(1,1),"%a%");
      assertEquals(1, posts.size());
    } finally {
      session.close();
    }
  }
View Full Code Here


  @Test
  public void shouldSelectListOfPostsLikeTwoParameters() {
    SqlSession session = sqlSessionFactory.openSession();
    try {
      BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
      List<Post> posts = mapper.selectPostsLikeSubjectAndBody(new RowBounds(1,1),"%a%","%a%");
      assertEquals(1, posts.size());
    } finally {
      session.close();
    }
  }
View Full Code Here

     * @throws Throwable 抛出异常
     */
    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        final Object[] args = invocation.getArgs();
        RowBounds rowBounds = (RowBounds) args[2];
        if (LOCAL_PAGE.get() == null && rowBounds == RowBounds.DEFAULT) {
            return invocation.proceed();
        } else {
            //忽略RowBounds-否则会进行Mybatis自带的内存分页
            args[2] = RowBounds.DEFAULT;
View Full Code Here

  void processIntercept(final Object[] queryArgs) {
    //queryArgs = query(MappedStatement ms, Object parameter, RowBounds rowBounds, ResultHandler resultHandler)
    MappedStatement ms = (MappedStatement)queryArgs[MAPPED_STATEMENT_INDEX];
    Object parameter = queryArgs[PARAMETER_INDEX];
    final RowBounds rowBounds = (RowBounds)queryArgs[ROWBOUNDS_INDEX];
    int offset = rowBounds.getOffset();
    int limit = rowBounds.getLimit();
   
    if(dialect.supportsLimit() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) {
      BoundSql boundSql = ms.getBoundSql(parameter);
      String sql = boundSql.getSql().trim();
      if (dialect.supportsLimitOffset()) {
        sql = dialect.getLimitString(sql, offset, limit);
        offset = RowBounds.NO_ROW_OFFSET;
      } else {
        sql = dialect.getLimitString(sql, 0, limit);
      }
      limit = RowBounds.NO_ROW_LIMIT;
     
      queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset,limit);
      BoundSql newBoundSql = new BoundSql(ms.getConfiguration(),sql, boundSql.getParameterMappings(), boundSql.getParameterObject());
      MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
      queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
    }
  }
View Full Code Here

    }
   
    public List selectList(final String statement,final Object parameter,final int offset,final int limit) {
      return (List)execute(new SqlSessionCallback() {
        public Object doInSession(SqlSession session) {
          return session.selectList(statement, parameter, new RowBounds(offset,limit));
        }
      });
    }
View Full Code Here

  @Override
  public Object intercept(Invocation invocation) throws Throwable {
    final MappedStatement mappedStatement = this.getMappedStatement(invocation);
    final Object parameter = this.getParameter(invocation);
    final RowBounds rowBounds = this.getRowBounds(invocation);

    final int offset = rowBounds.getOffset();
    final int limit = rowBounds.getLimit();

    if (dialect.supportLimit()
        && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) {
      BoundSql boundSql = mappedStatement.getBoundSql(parameter);
      String sql = boundSql.getSql().trim();
View Full Code Here

    LOG.info("Executing partial query with skipRows = " + skipRows + " and "
        + "maxRows = " + maxRows);
    SqlSession session = getSqlSession();
    try {
      rows = session.selectList("IbatisDBClient.getAll", null,
                                new RowBounds(skipRows, maxRows));
      LOG.info("Sucessfully executed partial query with skipRows = "
          + skipRows + " and maxRows = " + maxRows);
    } catch (RuntimeException e) {
      checkDBConnection(session, e);
      rows = new ArrayList<Map<String, Object>>();
View Full Code Here

    paramMap.put("value", keyValue);
    LOG.info("Executing partial parametrized query with keyValue = " + keyValue);
    SqlSession session = getSqlSession();
    try {
      rows = session.selectList("IbatisDBClient.getAll", paramMap,
                                new RowBounds(skipRows, maxRows));
      LOG.info("Sucessfully executed partial parametrized query with keyValue = "
          + keyValue);
    } catch (RuntimeException e) {
      checkDBConnection(session, e);
      rows = new ArrayList<Map<String, Object>>();
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

  public List<GroupMembershipDto> selectGroups(GroupMembershipQuery query, Long userId, int offset, int limit) {
    SqlSession session = mybatis.openSession(false);
    try {
      Map<String, Object> params = ImmutableMap.of("query", query, "userId", userId);
      return session.selectList("org.sonar.core.user.GroupMembershipMapper.selectGroups", params, new RowBounds(offset, limit));
    } finally {
      MyBatis.closeQuietly(session);
    }
  }
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.