Search in sources :

Example 1 with BlogMapper

use of org.apache.ibatis.domain.blog.mappers.BlogMapper in project mybatis-3 by mybatis.

the class SqlSessionTest method shouldSelectAllPostsUsingMapperClass.

@Test
void shouldSelectAllPostsUsingMapperClass() {
    try (SqlSession session = sqlMapper.openSession()) {
        BlogMapper mapper = session.getMapper(BlogMapper.class);
        List<Map> posts = mapper.selectAllPosts();
        assertEquals(5, posts.size());
    }
}
Also used : BlogMapper(org.apache.ibatis.domain.blog.mappers.BlogMapper) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.jupiter.api.Test)

Example 2 with BlogMapper

use of org.apache.ibatis.domain.blog.mappers.BlogMapper in project mybatis-3 by mybatis.

the class SqlSessionTest method shouldLimitResultsUsingMapperClass.

@Test
void shouldLimitResultsUsingMapperClass() {
    try (SqlSession session = sqlMapper.openSession()) {
        BlogMapper mapper = session.getMapper(BlogMapper.class);
        List<Map> posts = mapper.selectAllPosts(new RowBounds(0, 2), null);
        assertEquals(2, posts.size());
        assertEquals(1, posts.get(0).get("ID"));
        assertEquals(2, posts.get(1).get("ID"));
    }
}
Also used : BlogMapper(org.apache.ibatis.domain.blog.mappers.BlogMapper) AuthorMapperWithRowBounds(org.apache.ibatis.domain.blog.mappers.AuthorMapperWithRowBounds) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.jupiter.api.Test)

Example 3 with BlogMapper

use of org.apache.ibatis.domain.blog.mappers.BlogMapper in project mybatis-3 by mybatis.

the class SqlSessionTest method shouldOffsetAndLimitResultsUsingMapperClass.

@Test
void shouldOffsetAndLimitResultsUsingMapperClass() {
    try (SqlSession session = sqlMapper.openSession()) {
        BlogMapper mapper = session.getMapper(BlogMapper.class);
        List<Map> posts = mapper.selectAllPosts(new RowBounds(2, 3));
        assertEquals(3, posts.size());
        assertEquals(3, posts.get(0).get("ID"));
        assertEquals(4, posts.get(1).get("ID"));
        assertEquals(5, posts.get(2).get("ID"));
    }
}
Also used : BlogMapper(org.apache.ibatis.domain.blog.mappers.BlogMapper) AuthorMapperWithRowBounds(org.apache.ibatis.domain.blog.mappers.AuthorMapperWithRowBounds) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.jupiter.api.Test)

Aggregations

HashMap (java.util.HashMap)3 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 BaseDataTest (org.apache.ibatis.BaseDataTest)3 BlogMapper (org.apache.ibatis.domain.blog.mappers.BlogMapper)3 Test (org.junit.jupiter.api.Test)3 AuthorMapperWithRowBounds (org.apache.ibatis.domain.blog.mappers.AuthorMapperWithRowBounds)2