use of com.github.pagehelper.mapper.UserMapper in project Mybatis-PageHelper by pagehelper.
the class SecondCacheTest method test2.
@Test
public void test2() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
try {
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<User> list = userMapper.selectGreterThanId(10);
assertEquals(10, list.size());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.UserMapper in project Mybatis-PageHelper by pagehelper.
the class CollectionMapTest method test.
@Test
public void test() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
try {
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 5);
List<User> list1 = userMapper.selectGreterThanId(1);
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 5);
List<User> list2 = userMapper.selectCollectionMap();
assertEquals(5, list2.size());
assertEquals(183, ((Page<?>) list2).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.UserMapper in project Mybatis-PageHelper by pagehelper.
the class EnumTest method testCloseable.
@Test
public void testCloseable() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
PageHelper.startPage(1, 2);
List<UserCode> userCodes = userMapper.selectByCode(Code.LR);
Assert.assertEquals(1, userCodes.size());
sqlSession.close();
}
use of com.github.pagehelper.mapper.UserMapper in project Mybatis-PageHelper by pagehelper.
the class TestExists method testExists.
/**
* union的count查询sql特殊
*/
@Test
public void testExists() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
try {
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10);
List<User> list = userMapper.selectExists();
assertEquals(101, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(83, ((Page<?>) list).getTotal());
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(2, 10);
list = userMapper.selectExists();
assertEquals(111, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(83, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
use of com.github.pagehelper.mapper.UserMapper in project Mybatis-PageHelper by pagehelper.
the class TestDynamicChoose method testMapperWithStartPage_OrderBy.
/**
* 使用Mapper接口调用时,使用PageHelper.startPage效果更好,不需要添加Mapper接口参数
*/
@Test
public void testMapperWithStartPage_OrderBy() {
SqlSession sqlSession = MybatisHelper.getSqlSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
try {
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10, "id desc");
List<User> list = userMapper.selectChoose(183, 2);
assertEquals(182, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(182, ((Page<?>) list).getTotal());
// 获取第1页,10条内容,默认查询总数count
PageHelper.startPage(1, 10, "id desc");
list = userMapper.selectChoose(183, 2);
assertEquals(182, list.get(0).getId());
assertEquals(10, list.size());
assertEquals(182, ((Page<?>) list).getTotal());
} finally {
sqlSession.close();
}
}
Aggregations