use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectListOfBlogsStatement.
@Test
void shouldExecuteBoundSelectListOfBlogsStatement() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
List<Blog> blogs = mapper.selectBlogs();
assertEquals(2, blogs.size());
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteMultipleBoundSelectMapOfBlogsByIdInSameSessionWithoutClearingLocalCache.
@Test
void shouldExecuteMultipleBoundSelectMapOfBlogsByIdInSameSessionWithoutClearingLocalCache() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Map<Integer, Blog> blogs = mapper.selectBlogsAsMapById();
Map<Integer, Blog> moreBlogs = mapper.selectBlogsAsMapById();
assertEquals(2, blogs.size());
assertEquals(2, moreBlogs.size());
for (Map.Entry<Integer, Blog> blogEntry : blogs.entrySet()) {
assertEquals(blogEntry.getKey(), (Integer) blogEntry.getValue().getId());
}
for (Map.Entry<Integer, Blog> blogEntry : moreBlogs.entrySet()) {
assertEquals(blogEntry.getKey(), (Integer) blogEntry.getValue().getId());
}
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectOneBlogStatement.
@Test
void shouldExecuteBoundSelectOneBlogStatement() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog blog = mapper.selectBlog(1);
assertEquals(1, blog.getId());
assertEquals("Jim Business", blog.getTitle());
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectBlogWithPostsAndAuthorUsingSubSelects.
@Test
void shouldSelectBlogWithPostsAndAuthorUsingSubSelects() {
try (SqlSession session = sqlMapper.openSession()) {
Blog blog = session.selectOne("org.apache.ibatis.domain.blog.mappers.BlogMapper.selectBlogWithPostsUsingSubSelect", 1);
assertEquals("Jim Business", blog.getTitle());
assertEquals(2, blog.getPosts().size());
assertEquals("Corn nuts", blog.getPosts().get(0).getSubject());
assertEquals(101, blog.getAuthor().getId());
assertEquals("jim", blog.getAuthor().getUsername());
}
}
use of org.apache.ibatis.domain.blog.Blog in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectBlogWithPostsAndAuthorUsingSubSelectsLazily.
@Test
void shouldSelectBlogWithPostsAndAuthorUsingSubSelectsLazily() {
try (SqlSession session = sqlMapper.openSession()) {
Blog blog = session.selectOne("org.apache.ibatis.domain.blog.mappers.BlogMapper.selectBlogWithPostsUsingSubSelectLazily", 1);
Assertions.assertTrue(blog instanceof Proxy);
assertEquals("Jim Business", blog.getTitle());
assertEquals(2, blog.getPosts().size());
assertEquals("Corn nuts", blog.getPosts().get(0).getSubject());
assertEquals(101, blog.getAuthor().getId());
assertEquals("jim", blog.getAuthor().getUsername());
}
}
Aggregations