org.apache.ibatis.executor.resultset.ResultSetHandler Java Examples

The following examples show how to use org.apache.ibatis.executor.resultset.ResultSetHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageResultInterceptor.java    From joyqueue with Apache License 2.0 6 votes vote down vote up
@Override
public Object intercept(Invocation invocation) throws Throwable {
    // 目标对象转换
    ResultSetHandler resultSetHandler = (ResultSetHandler) invocation.getTarget();

    // 获取MappedStatement,Configuration对象
    MetaObject metaObject =
            MetaObject.forObject(resultSetHandler, new DefaultObjectFactory(), new DefaultObjectWrapperFactory(), new DefaultReflectorFactory());
    MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("mappedStatement");
    String statement = mappedStatement.getId();
    if (!isPageSql(statement,metaObject.getValue("boundSql.parameterObject"))) {
        return invocation.proceed();
    }

    // 获取分页参数
    QPageQuery pageQuery = (QPageQuery) metaObject.getValue("boundSql.parameterObject");

    List<PageResult> result = new ArrayList<PageResult>(1);
    PageResult page = new PageResult();
    page.setPagination(pageQuery.getPagination());
    page.setResult((List) invocation.proceed());
    result.add(page);

    return result;
}
 
Example #2
Source File: PaginationInterceptor.java    From belling-admin with Apache License 2.0 5 votes vote down vote up
/**
 * 只拦截这两种类型的 <br>
 * StatementHandler <br>
 * ResultSetHandler
 * 
 * @param target
 * @return
 */
@Override
public Object plugin(Object target) {
	if (target instanceof StatementHandler || target instanceof ResultSetHandler) {
		return Plugin.wrap(target, this);
	} else {
		return target;
	}
}
 
Example #3
Source File: PageInterceptor.java    From everyone-java-blog with Apache License 2.0 5 votes vote down vote up
@Override
public Object plugin(Object target) {
    if (target instanceof StatementHandler) {
        return Plugin.wrap(target, this);
    } else if (target instanceof ResultSetHandler) {
        return Plugin.wrap(target, this);
    } else {
        return target;
    }
}