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.github.pagehelper.test.rowbounds.RowBoundsTest.java

License:Open Source License

@Test
public void testNamespaceWithRowBounds2() {
    SqlSession sqlSession = MybatisRowBoundsHelper.getSqlSession();
    try {/*w  w  w.  ja  v a2  s. c o  m*/
        //?010?
        List<Country> list = sqlSession.selectList("selectIf", null, new RowBounds(1, 10));
        assertEquals(10, list.size());
        assertEquals(183, ((Page<?>) list).getTotal());
        //??
        assertEquals(1, list.get(0).getId());
        assertEquals(10, list.get(list.size() - 1).getId());

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", 10);
        //?1010?
        list = sqlSession.selectList("selectIf", map, new RowBounds(10, 10));
        assertEquals(10, list.size());
        assertEquals(173, ((Page<?>) list).getTotal());
        //??
        assertEquals(101, list.get(0).getId());
        assertEquals(110, list.get(list.size() - 1).getId());
    } finally {
        sqlSession.close();
    }
}

From source file:com.github.pagehelper.test.rowbounds.RowBoundsTest.java

License:Open Source License

/**
 * Mapper?PageHelper.startPage??Mapper??
 *///from   ww w  .  j a  v a2  s. c  o  m
@Test
public void testWithRowboundsAndCountTrue() {
    SqlSession sqlSession = MybatisRowBoundsHelper.getSqlSession();
    CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
    try {
        //limit=0,?count,????rounbounds?count?-1
        //?-1
        List<Country> list = countryMapper.selectAll(new RowBounds(1, 0));
        PageInfo<Country> page = new PageInfo<Country>(list);
        assertEquals(0, list.size());
        assertEquals(183, page.getTotal());

        //pageSize<0?
        list = countryMapper.selectAll(new RowBounds(1, -100));
        page = new PageInfo<Country>(list);
        assertEquals(0, list.size());
        assertEquals(183, page.getTotal());
    } finally {
        sqlSession.close();
    }
}

From source file:com.glaf.apps.member.service.impl.WxMemberServiceImpl.java

License:Apache License

public List<WxMember> getWxMembersByQueryCriteria(int start, int pageSize, WxMemberQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<WxMember> rows = sqlSessionTemplate.selectList("getWxMembers", query, rowBounds);
    return rows;/*from w  w w  . j av a2s.  c om*/
}

From source file:com.glaf.apps.message.service.impl.WxMessageServiceImpl.java

License:Apache License

public List<WxMessage> getWxMessagesByQueryCriteria(int start, int pageSize, WxMessageQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<WxMessage> rows = sqlSessionTemplate.selectList("getWxMessages", query, rowBounds);
    return rows;/*w ww .j  a  v a 2  s  . c  o m*/
}

From source file:com.glaf.apps.vote.service.impl.WxVoteItemServiceImpl.java

License:Apache License

public List<WxVoteItem> getWxVoteItemsByQueryCriteria(int start, int pageSize, WxVoteItemQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<WxVoteItem> rows = sqlSessionTemplate.selectList("getWxVoteItems", query, rowBounds);
    return rows;//from ww  w  . j  a va  2 s  . c  om
}

From source file:com.glaf.apps.vote.service.impl.WxVoteResultServiceImpl.java

License:Apache License

public List<WxVoteResult> getWxVoteResultsByQueryCriteria(int start, int pageSize, WxVoteResultQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<WxVoteResult> rows = sqlSessionTemplate.selectList("getWxVoteResults", query, rowBounds);
    return rows;//w  ww  .ja  va2s.  c  o  m
}

From source file:com.glaf.apps.vote.service.impl.WxVoteServiceImpl.java

License:Apache License

public List<WxVote> getWxVotesByQueryCriteria(int start, int pageSize, WxVoteQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<WxVote> rows = sqlSessionTemplate.selectList("getWxVotes", query, rowBounds);
    return rows;//from ww w .j  av  a 2  s .c o m
}

From source file:com.glaf.base.district.service.DistrictServiceImpl.java

License:Apache License

/**
 * ????//from w  ww  .  j av  a 2s.  com
 * 
 * @return
 */
public List<DistrictEntity> getDistrictsByQueryCriteria(int start, int pageSize, DistrictQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<DistrictEntity> rows = sqlSession.selectList("getDistricts", query, rowBounds);
    return rows;
}

From source file:com.glaf.base.modules.others.service.mybatis.AttachmentServiceImpl.java

License:Apache License

public List<Attachment> getAttachmentsByQueryCriteria(int start, int pageSize, AttachmentQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<Attachment> rows = sqlSessionTemplate.selectList("getAttachments", query, rowBounds);
    return rows;//w w  w  .  ja va 2s  .  c  o  m
}

From source file:com.glaf.base.modules.others.service.mybatis.AuditServiceImpl.java

License:Apache License

public List<Audit> getAuditsByQueryCriteria(int start, int pageSize, AuditQuery query) {
    RowBounds rowBounds = new RowBounds(start, pageSize);
    List<Audit> rows = sqlSessionTemplate.selectList("getAudits", query, rowBounds);
    return rows;/*from ww  w.  ja  v  a  2  s . co  m*/
}