Search in sources :

Example 71 with Country

use of com.github.pagehelper.model.Country in project Mybatis-PageHelper by pagehelper.

the class TestGroupBy method testGroupBy.

@Test
public void testGroupBy() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
    try {
        //获取第1页,10条内容,默认查询总数count
        Page<Country> page = PageHelper.startPage(1, 10);
        countryMapper.selectGroupBy();
        //1,'Angola','AO'
        assertEquals(1, page.get(0).getId());
        assertEquals(10, page.size());
        assertEquals(183, page.getTotal());
        PageInfo<Country> pageInfo = page.toPageInfo();
        System.out.println(pageInfo);
        //获取第2页,10条内容,默认查询总数count
        page = PageHelper.startPage(2, 10);
        countryMapper.selectGroupBy();
        //1,'Angola','AO'
        assertEquals(1, page.get(0).getId());
        assertEquals(10, page.size());
        assertEquals(183, page.getTotal());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) CountryMapper(com.github.pagehelper.mapper.CountryMapper) Country(com.github.pagehelper.model.Country) Test(org.junit.Test)

Aggregations

Country (com.github.pagehelper.model.Country)71 SqlSession (org.apache.ibatis.session.SqlSession)71 Test (org.junit.Test)71 CountryMapper (com.github.pagehelper.mapper.CountryMapper)57 RowBounds (org.apache.ibatis.session.RowBounds)14 HashMap (java.util.HashMap)12 PageInfo (com.github.pagehelper.PageInfo)11 ArrayList (java.util.ArrayList)5 PageRowBounds (com.github.pagehelper.PageRowBounds)4 CountryExample (com.github.pagehelper.model.CountryExample)2 ISelect (com.github.pagehelper.ISelect)1 CountryQueryModel (com.github.pagehelper.model.CountryQueryModel)1 Map (java.util.Map)1