Search in sources :

Example 56 with CountryMapper

use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.

the class SecondCacheTest method test3.

@Test
public void test3() {
    SqlSession sqlSession = MybatisHelper.getSqlSession();
    CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
    try {
        //获取第1页,10条内容,默认查询总数count
        PageHelper.startPage(1, 10);
        List<Country> list = countryMapper.selectGreterThanId(10);
        assertEquals(10, list.size());
    } 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)

Example 57 with CountryMapper

use of com.github.pagehelper.mapper.CountryMapper 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

CountryMapper (com.github.pagehelper.mapper.CountryMapper)57 Country (com.github.pagehelper.model.Country)57 SqlSession (org.apache.ibatis.session.SqlSession)57 Test (org.junit.Test)57 PageInfo (com.github.pagehelper.PageInfo)11 RowBounds (org.apache.ibatis.session.RowBounds)7 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)4 PageRowBounds (com.github.pagehelper.PageRowBounds)2 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