Search in sources :

Example 61 with Author

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

the class SqlSessionTest method shouldExecuteSelectOneAuthorUsingMapperClass.

@Test
public void shouldExecuteSelectOneAuthorUsingMapperClass() {
    SqlSession session = sqlMapper.openSession();
    try {
        AuthorMapper mapper = session.getMapper(AuthorMapper.class);
        Author author = mapper.selectAuthor(101);
        assertEquals(101, author.getId());
    } finally {
        session.close();
    }
}
Also used : AuthorMapper(org.apache.ibatis.domain.blog.mappers.AuthorMapper) ImmutableAuthor(org.apache.ibatis.domain.blog.ImmutableAuthor) Author(org.apache.ibatis.domain.blog.Author) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Example 62 with Author

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

the class SqlSessionTest method shouldExecuteSelectOneAuthorUsingMapperClassWithResultHandler.

@Test
public void shouldExecuteSelectOneAuthorUsingMapperClassWithResultHandler() {
    SqlSession session = sqlMapper.openSession();
    try {
        DefaultResultHandler handler = new DefaultResultHandler();
        AuthorMapper mapper = session.getMapper(AuthorMapper.class);
        mapper.selectAuthor(101, handler);
        Author author = (Author) handler.getResultList().get(0);
        assertEquals(101, author.getId());
    } finally {
        session.close();
    }
}
Also used : AuthorMapper(org.apache.ibatis.domain.blog.mappers.AuthorMapper) ImmutableAuthor(org.apache.ibatis.domain.blog.ImmutableAuthor) Author(org.apache.ibatis.domain.blog.Author) DefaultResultHandler(org.apache.ibatis.executor.result.DefaultResultHandler) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Example 63 with Author

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

the class SqlSessionTest method shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsLinkedList.

@Test
public void shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsLinkedList() {
    SqlSession session = sqlMapper.openSession();
    try {
        AuthorMapper mapper = session.getMapper(AuthorMapper.class);
        Collection<Author> authors = mapper.selectAllAuthorsLinkedList();
        assertEquals(2, authors.size());
    } finally {
        session.close();
    }
}
Also used : AuthorMapper(org.apache.ibatis.domain.blog.mappers.AuthorMapper) ImmutableAuthor(org.apache.ibatis.domain.blog.ImmutableAuthor) Author(org.apache.ibatis.domain.blog.Author) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Example 64 with Author

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

the class SqlSessionTest method shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsAnArray.

@Test
public void shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsAnArray() {
    SqlSession session = sqlMapper.openSession();
    try {
        AuthorMapper mapper = session.getMapper(AuthorMapper.class);
        Author[] authors = mapper.selectAllAuthorsArray();
        assertEquals(2, authors.length);
    } finally {
        session.close();
    }
}
Also used : AuthorMapper(org.apache.ibatis.domain.blog.mappers.AuthorMapper) ImmutableAuthor(org.apache.ibatis.domain.blog.ImmutableAuthor) Author(org.apache.ibatis.domain.blog.Author) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Example 65 with Author

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

the class SqlSessionTest method shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsSet.

@Test
public void shouldExecuteSelectAllAuthorsUsingMapperClassThatReturnsSet() {
    SqlSession session = sqlMapper.openSession();
    try {
        AuthorMapper mapper = session.getMapper(AuthorMapper.class);
        Collection<Author> authors = mapper.selectAllAuthorsSet();
        assertEquals(2, authors.size());
    } finally {
        session.close();
    }
}
Also used : AuthorMapper(org.apache.ibatis.domain.blog.mappers.AuthorMapper) ImmutableAuthor(org.apache.ibatis.domain.blog.ImmutableAuthor) Author(org.apache.ibatis.domain.blog.Author) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Aggregations

Author (org.apache.ibatis.domain.blog.Author)70 Test (org.junit.Test)68 BaseDataTest (org.apache.ibatis.BaseDataTest)45 ImmutableAuthor (org.apache.ibatis.domain.blog.ImmutableAuthor)20 MappedStatement (org.apache.ibatis.mapping.MappedStatement)14 AuthorMapper (org.apache.ibatis.domain.blog.mappers.AuthorMapper)13 DefaultObjectFactory (org.apache.ibatis.reflection.factory.DefaultObjectFactory)13 JdbcTransaction (org.apache.ibatis.transaction.jdbc.JdbcTransaction)12 ArrayList (java.util.ArrayList)8 Configuration (org.apache.ibatis.session.Configuration)7 SqlSession (org.apache.ibatis.session.SqlSession)7 HashMap (java.util.HashMap)4 Blog (org.apache.ibatis.domain.blog.Blog)3 DraftPost (org.apache.ibatis.domain.blog.DraftPost)3 Post (org.apache.ibatis.domain.blog.Post)3 StaticSqlSource (org.apache.ibatis.builder.StaticSqlSource)2 Comment (org.apache.ibatis.domain.blog.Comment)2 Section (org.apache.ibatis.domain.blog.Section)2 Tag (org.apache.ibatis.domain.blog.Tag)2 CglibProxyFactory (org.apache.ibatis.executor.loader.cglib.CglibProxyFactory)2