I followed this example : https://code.google.com/p/mybatis/wiki/ResultHandlerExample This is my interface:
public interface CountryDirRdbMapper {
public static class CountryDirBaseItemWithText {
public CountryDirBaseItem baseItem;
}
public List<CountryDirBaseItem> select(ResultHandler handler);
}
This is my xml mapper
<resultMap id="readItemsRM" type="CountryDirRdbMapper$CountryDirBaseItemWithText">
<association property="baseItem" javaType="CountryDirBaseItem">
<id property="id" column="Id"/>
<result property="comment" column="Comment"/>
</association>
</resultMap>
This code form my DAO:
SqlSession session = MyBatisConnectionFactory.getSqlSessionFactory().openSession(true);
List<CountryDirBaseItem> list;
try{
CountryDirRdbMapper mapper = session.getMapper(CountryDirRdbMapper.class);
class MyResultHandler implements ResultHandler {
@Override
public void handleResult(ResultContext context) {
System.out.println("#########################");
}
}
MyResultHandler handler=new MyResultHandler();
list= mapper.select(handler);
}
finally {
session.close();
}
However the result handler is never invoked. At the example I follow people say that have the same problem. So how to make it work? Or result handler is not supported in mybatis 3?