Search in sources :

Example 1 with AuthorMapperWithMultipleHandlers

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

the class SqlSessionTest method shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers.

@Test(expected = BindingException.class)
public void shouldFailSelectOneAuthorUsingMapperClassWithTwoResultHandlers() {
    Configuration configuration = new Configuration(sqlMapper.getConfiguration().getEnvironment());
    configuration.addMapper(AuthorMapperWithMultipleHandlers.class);
    SqlSessionFactory sqlMapperWithMultipleHandlers = new DefaultSqlSessionFactory(configuration);
    SqlSession sqlSession = sqlMapperWithMultipleHandlers.openSession();
    try {
        DefaultResultHandler handler1 = new DefaultResultHandler();
        DefaultResultHandler handler2 = new DefaultResultHandler();
        AuthorMapperWithMultipleHandlers mapper = sqlSession.getMapper(AuthorMapperWithMultipleHandlers.class);
        mapper.selectAuthor(101, handler1, handler2);
    } finally {
        sqlSession.close();
    }
}
Also used : DefaultSqlSessionFactory(org.apache.ibatis.session.defaults.DefaultSqlSessionFactory) DefaultSqlSessionFactory(org.apache.ibatis.session.defaults.DefaultSqlSessionFactory) AuthorMapperWithMultipleHandlers(org.apache.ibatis.domain.blog.mappers.AuthorMapperWithMultipleHandlers) DefaultResultHandler(org.apache.ibatis.executor.result.DefaultResultHandler) BaseDataTest(org.apache.ibatis.BaseDataTest) Test(org.junit.Test)

Aggregations

BaseDataTest (org.apache.ibatis.BaseDataTest)1 AuthorMapperWithMultipleHandlers (org.apache.ibatis.domain.blog.mappers.AuthorMapperWithMultipleHandlers)1 DefaultResultHandler (org.apache.ibatis.executor.result.DefaultResultHandler)1 DefaultSqlSessionFactory (org.apache.ibatis.session.defaults.DefaultSqlSessionFactory)1 Test (org.junit.Test)1