use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestParameterArray method testMapperWithStartPage.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testMapperWithStartPage() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectAllOrderByArray(new Integer[] { 1, 2 });
assertEquals(3, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(181, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestParameterList 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<Integer> paList = new ArrayList<Integer>();
paList.add(1);
paList.add(2);
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectAllOrderByList(paList);
assertEquals(3, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(181, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestParameterMap method testMapperWithStartPage.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testMapperWithStartPage() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
Map<String, Object> map = new HashMap<String, Object>();
map.put("order1", 1);
map.put("order2", 2);
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectAllOrderByMap(map);
assertEquals(3, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(181, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestParameterOne method testMapperWithStartPage.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testMapperWithStartPage() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectGreterThanId(1);
assertEquals(2, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(182, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.CountryMapper in project Mybatis-PageHelper by pagehelper.
the class TestLeftjoin method testLeftjoin.
/**
* left join的count查询sql特殊
*/
@Test
public void testLeftjoin() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
CountryMapper countryMapper = sqlSession.getMapper(CountryMapper.class);
try {
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<Country> list = countryMapper.selectLeftjoin();
assertEquals(1, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(183, ((Page<?>) list).getTotal());
//获取第1页,10条内容,默认查询总数count
PageHelper.startPage(2, 10);
list = countryMapper.selectLeftjoin();
assertEquals(11, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(183, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
Aggregations