本文整理匯總了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;
}
}