use of org.apache.ibatis.executor.result.DefaultResultHandler in project mybatis-3 by mybatis.
the class BindingTest method shouldExecuteMultipleBoundSelectOfBlogsByIdInWithProvidedResultHandlerBetweenSessions.
@Test
public void shouldExecuteMultipleBoundSelectOfBlogsByIdInWithProvidedResultHandlerBetweenSessions() {
SqlSession session = sqlSessionFactory.openSession();
try {
final DefaultResultHandler handler = new DefaultResultHandler();
session.select("selectBlogsAsMapById", handler);
//new session
session.close();
session = sqlSessionFactory.openSession();
final DefaultResultHandler moreHandler = new DefaultResultHandler();
session.select("selectBlogsAsMapById", moreHandler);
assertEquals(2, handler.getResultList().size());
assertEquals(2, moreHandler.getResultList().size());
} finally {
session.close();
}
}
use of org.apache.ibatis.executor.result.DefaultResultHandler 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();
}
}
use of org.apache.ibatis.executor.result.DefaultResultHandler in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldFailExecutingAnAnnotatedMapperClassWithResultHandler.
@Test(expected = BindingException.class)
public void shouldFailExecutingAnAnnotatedMapperClassWithResultHandler() {
SqlSession session = sqlMapper.openSession();
try {
DefaultResultHandler handler = new DefaultResultHandler();
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
mapper.selectAuthor2(101, handler);
Author author = (Author) handler.getResultList().get(0);
assertEquals(101, author.getId());
} finally {
session.close();
}
}
use of org.apache.ibatis.executor.result.DefaultResultHandler in project mybatis-3 by mybatis.
the class SqlSessionTest method shouldSelectAuthorsUsingMapperClassWithResultHandler.
@Test
public void shouldSelectAuthorsUsingMapperClassWithResultHandler() {
SqlSession session = sqlMapper.openSession();
try {
DefaultResultHandler handler = new DefaultResultHandler();
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
mapper.selectAllAuthors(handler);
assertEquals(2, handler.getResultList().size());
} finally {
session.close();
}
}
use of org.apache.ibatis.executor.result.DefaultResultHandler in project mybatis-3 by mybatis.
the class DefaultResultSetHandler method handleRefCursorOutputParameter.
private void handleRefCursorOutputParameter(ResultSet rs, ParameterMapping parameterMapping, MetaObject metaParam) throws SQLException {
if (rs == null) {
return;
}
try {
final String resultMapId = parameterMapping.getResultMapId();
final ResultMap resultMap = configuration.getResultMap(resultMapId);
final DefaultResultHandler resultHandler = new DefaultResultHandler(objectFactory);
final ResultSetWrapper rsw = new ResultSetWrapper(rs, configuration);
handleRowValues(rsw, resultMap, resultHandler, new RowBounds(), null);
metaParam.setValue(parameterMapping.getProperty(), resultHandler.getResultList());
} finally {
// issue #228 (close resultsets)
closeResultSet(rs);
}
}
Aggregations