use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class RemoveOrderTest method simpleOrderTest.
@Test
public void simpleOrderTest() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
//主要观看查询执行count查询的sql
try {
PageHelper.startPage(1, 50);
List<Country> list = countryMapper.selectAllOrderby();
//总数183
Assert.assertEquals(183, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestDistinct method test.
@Test
public void test() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectDistinct();
assertEquals(10, list.size());
assertEquals(24, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestDynamicForeach method testMapperWithStartPage2.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testMapperWithStartPage2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
List<Long> idList = new ArrayList<Long>();
idList.add(1L);
idList.add(2L);
idList.add(3L);
PageHelper.startPage(1, 2);
List<Country> list = countryMapper.selectByIdList2(idList);
assertEquals(1, list.get(0).getId());
assertEquals(2, list.size());
assertEquals(3, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestDynamicForeach method testMapperWithStartPage.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testMapperWithStartPage() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
List<Long> idList = new ArrayList<Long>();
idList.add(1L);
idList.add(2L);
idList.add(3L);
PageHelper.startPage(1, 2);
List<Country> list = countryMapper.selectByIdList(idList);
assertEquals(1, list.get(0).getId());
assertEquals(2, list.size());
assertEquals(3, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestDynamicIf method testCountCache.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testCountCache() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectIf(1);
assertEquals(2, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(182, ((Page<?>) list).getTotal());
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
list = countryMapper.selectIf(null);
assertEquals(1, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(183, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
Aggregations