本文整理汇总了Java中org.apache.ibatis.session.RowBounds.getLimit方法的典型用法代码示例。如果您正苦于以下问题:Java RowBounds.getLimit方法的具体用法?Java RowBounds.getLimit怎么用?Java RowBounds.getLimit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ibatis.session.RowBounds
的用法示例。
在下文中一共展示了RowBounds.getLimit方法的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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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;
}
}