use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BaseExecutorTest method shouldFetchOneOrphanedPostWithNoBlog.
@Test
void shouldFetchOneOrphanedPostWithNoBlog() throws Exception {
Executor executor = createExecutor(new JdbcTransaction(ds, null, false));
try {
MappedStatement selectBlog = ExecutorTestHelper.prepareComplexSelectBlogMappedStatement(config);
MappedStatement selectPost = ExecutorTestHelper.prepareSelectPostMappedStatement(config);
config.addMappedStatement(selectBlog);
config.addMappedStatement(selectPost);
List<Post> posts = executor.query(selectPost, 5, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
executor.flushStatements();
executor.rollback(true);
assertEquals(1, posts.size());
Post post = posts.get(0);
assertNull(post.getBlog());
} finally {
executor.rollback(true);
executor.close(false);
}
}
use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BindingTest method shouldSelectListOfPostsLikeTwoParameters.
@Test
void shouldSelectListOfPostsLikeTwoParameters() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
List<Post> posts = mapper.selectPostsLikeSubjectAndBody(new RowBounds(1, 1), "%a%", "%a%");
assertEquals(1, posts.size());
}
}
use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BindingTest method shouldFindPostsInList.
@Test
void shouldFindPostsInList() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundAuthorMapper mapper = session.getMapper(BoundAuthorMapper.class);
List<Post> posts = mapper.findPostsInList(new ArrayList<Integer>() {
{
add(1);
add(3);
add(5);
}
});
assertEquals(3, posts.size());
session.rollback();
}
}
use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteBoundSelectOneBlogStatementWithConstructorUsingXMLConfig.
@Test
void shouldExecuteBoundSelectOneBlogStatementWithConstructorUsingXMLConfig() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
Blog blog = mapper.selectBlogByIdUsingConstructor(1);
assertEquals(1, blog.getId());
assertEquals("Jim Business", blog.getTitle());
assertNotNull(blog.getAuthor(), "author should not be null");
List<Post> posts = blog.getPosts();
assertTrue(posts != null && !posts.isEmpty(), "posts should not be empty");
}
}
use of org.apache.ibatis.domain.blog.Post in project mybatis-3 by mybatis.
the class BindingTest method shouldSelectListOfPostsLike.
@Test
void shouldSelectListOfPostsLike() {
try (SqlSession session = sqlSessionFactory.openSession()) {
BoundBlogMapper mapper = session.getMapper(BoundBlogMapper.class);
List<Post> posts = mapper.selectPostsLike(new RowBounds(1, 1), "%a%");
assertEquals(1, posts.size());
}
}
Aggregations