当前位置: 首页>>代码示例>>Java>>正文


Java RowBounds.getOffset方法代码示例

本文整理汇总了Java中org.apache.ibatis.session.RowBounds.getOffset方法的典型用法代码示例。如果您正苦于以下问题:Java RowBounds.getOffset方法的具体用法?Java RowBounds.getOffset怎么用?Java RowBounds.getOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.session.RowBounds的用法示例。


在下文中一共展示了RowBounds.getOffset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPage

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
/**
 * 获取分页参数
 *
 * @param params RowBounds参数
 * @return 返回Page对象
 */
public PageHelper getPage(Object params) {
    PageHelper page = getLocalPage();
    if (page == null) {
        if (params instanceof RowBounds) {
            RowBounds rowBounds = (RowBounds) params;
            if (offsetAsPageNum) {
                page = new PageHelper(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount);
            } else {
                page = new PageHelper(rowBounds, rowBoundsWithCount);
            }
        } else {
            page = getPageFromObject(params);
        }
        setLocalPage(page);
    }
    //分页合理化
    if (page.getReasonable() == null) {
        page.setReasonable(reasonable);
    }
    //当设置为true的时候,如果pagesize设置为0(或RowBounds的limit=0),就不执行分页,返回全部结果
    if (page.getPageSizeZero() == null) {
        page.setPageSizeZero(pageSizeZero);
    }
    return page;
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:32,代码来源:SqlUtil.java

示例2: getPage

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
/**
 * 获取分页参数
 *
 * @param rowBounds
 *            RowBounds参数
 * @return 返回Page对象
 */
private Page getPage(RowBounds rowBounds) {
    Page page = LOCAL_PAGE.get();
    // 移除本地变量
    LOCAL_PAGE.remove();
    if (page == null) {
        if (offsetAsPageNum) {
            page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount);
        } else {
            page = new Page(rowBounds, rowBoundsWithCount);
        }
    }
    // 分页合理化
    if (page.getReasonable() == null) {
        page.setReasonable(reasonable);
    }
    // 当设置为true的时候,如果pagesize设置为0(或RowBounds的limit=0),就不执行分页,返回全部结果
    if (page.getPageSizeZero() == null) {
        page.setPageSizeZero(pageSizeZero);
    }
    return page;
}
 
开发者ID:PekingGo,项目名称:ipayquery,代码行数:29,代码来源:PageHelper.java

示例3: PageHelper

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
public PageHelper(RowBounds rowBounds, int total) {
    super(rowBounds.getLimit() > -1 ? rowBounds.getLimit() : 0);
    this.pageSize = rowBounds.getLimit();
    this.startRow = rowBounds.getOffset();
    //RowBounds方式默认不求count总数,如果想求count,可以修改这里为SQL_COUNT
    this.total = total;
    this.endRow = this.startRow + this.pageSize;
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:9,代码来源:PageHelper.java

示例4: processIntercept

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
void processIntercept(final Object[] queryArgs) {
	MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
	Object parameter = queryArgs[PARAMETER_INDEX];
	final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
	int offset = rowBounds.getOffset();
	int limit = rowBounds.getLimit();
	if (dialect.supportsLimit() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) {
		BoundSql boundSql = ms.getBoundSql(parameter);
		String sql = boundSql.getSql().trim();
		if (dialect.supportsLimitOffset()) {
			sql = dialect.getLimitString(sql, offset, limit);
			offset = RowBounds.NO_ROW_OFFSET;
		} else {
			sql = dialect.getLimitString(sql, 0, limit);
		}
		limit = RowBounds.NO_ROW_LIMIT;
		queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
		BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(),
				boundSql.getParameterObject());
		for (ParameterMapping mapping : boundSql.getParameterMappings()) {
			String prop = mapping.getProperty();
			if (boundSql.hasAdditionalParameter(prop)) {
				newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
			}
		}
		MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
		queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
	}
}
 
开发者ID:yi-jun,项目名称:aaden-pay,代码行数:30,代码来源:PagePluging.java

示例5: PageBounds

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
public PageBounds(RowBounds rowBounds) {
    if(rowBounds instanceof PageBounds){
        PageBounds pageBounds = (PageBounds)rowBounds;
        this.page = pageBounds.page;
        this.limit = pageBounds.limit;
        this.orders = pageBounds.orders;
        this.containsTotalCount = pageBounds.containsTotalCount;
        this.asyncTotalCount = pageBounds.asyncTotalCount;
    }else{
        this.page = (rowBounds.getOffset()/rowBounds.getLimit())+1;
        this.limit = rowBounds.getLimit();
    }

}
 
开发者ID:AsuraTeam,项目名称:asura,代码行数:15,代码来源:PageBounds.java

示例6: Page

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
public Page(RowBounds rowBounds, int total) {
    super(rowBounds.getLimit() > -1 ? rowBounds.getLimit() : 0);
    this.pageSize = rowBounds.getLimit();
    this.startRow = rowBounds.getOffset();
    // RowBounds方式默认不求count总数,如果想求count,可以修改这里为SQL_COUNT
    this.total = total;
    this.endRow = this.startRow + this.pageSize;
}
 
开发者ID:PekingGo,项目名称:ipayquery,代码行数:9,代码来源:Page.java

示例7: Pagination

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
public Pagination(RowBounds rowBounds) {
	this.limit = rowBounds.getLimit();
	this.offset = rowBounds.getOffset();
	this.page = offset / limit + 1;
}
 
开发者ID:jiangzongyao,项目名称:kettle_support_kettle8.0,代码行数:6,代码来源:Pagination.java

示例8: processIntercept

import org.apache.ibatis.session.RowBounds; //导入方法依赖的package包/类
void processIntercept(final Object[] queryArgs) throws Exception
{
	/*
	// 以下代码可根据数据源动态加载方言,用于多数据源的情况下
	Dialect dialect = this.dialect;
	String str = DynamicDataSource.getDbType();
	if(!str.equals("1"))
	{
		String dialectClass = this.properties.getProperty(str);
		try
		{
			System.out.println("dbType是" + str + ",加载动态方言:" + dialectClass);
			dialect = (Dialect) Class.forName(dialectClass).newInstance();
		}
		catch (Exception e)
		{
			throw new RuntimeException("无法初始化方言:" + dialectClass, e);
		}
	}
	*/
	final RowBounds rowBounds = (RowBounds) queryArgs[ROWBOUNDS_INDEX];
	int offset = rowBounds.getOffset();
	int limit = rowBounds.getLimit();
	if (dialect.supportsLimitOffset() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT))
	{
		MappedStatement ms = (MappedStatement) queryArgs[MAPPED_STATEMENT_INDEX];
		Object parameter = queryArgs[PARAMETER_INDEX];
		BoundSql boundSql = ms.getBoundSql(parameter);
		String sql = boundSql.getSql().trim();
		
		sql = dialect.getLimitString(sql, offset, limit);
		offset = RowBounds.NO_ROW_OFFSET;
		
		limit = RowBounds.NO_ROW_LIMIT;
		queryArgs[ROWBOUNDS_INDEX] = new RowBounds(offset, limit);
		BoundSql newBoundSql = new BoundSql(ms.getConfiguration(), sql, boundSql.getParameterMappings(), boundSql.getParameterObject());
		String prop;
		for(ParameterMapping p : boundSql.getParameterMappings())
		{
			prop = p.getProperty();
			if(boundSql.hasAdditionalParameter(prop))
			{
				newBoundSql.setAdditionalParameter(prop, boundSql.getAdditionalParameter(prop));
			}
		}
		MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql));
		queryArgs[MAPPED_STATEMENT_INDEX] = newMs;
	}
}
 
开发者ID:skeychen,项目名称:dswork,代码行数:50,代码来源:OffsetLimitInterceptor.java


注:本文中的org.apache.ibatis.session.RowBounds.getOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。