List of usage examples for org.apache.ibatis.session RowBounds getOffset
public int getOffset()
From source file:cn.myblog.uitl.MybatisPageHelper.Page.java
License:Open Source License
public Page(RowBounds rowBounds, int total) { super(rowBounds.getLimit()); this.pageSize = rowBounds.getLimit(); this.startRow = rowBounds.getOffset(); //RowBounds??countcount,?SQL_COUNT this.total = total; this.endRow = this.startRow + this.pageSize; }
From source file:cn.myblog.uitl.MybatisPageHelper.PageHelper.java
License:Open Source License
@Override public Object intercept(Invocation invocation) throws Throwable { final Object[] args = invocation.getArgs(); RowBounds rowBounds = (RowBounds) args[2]; if (localPage.get() == null && rowBounds == RowBounds.DEFAULT) { return invocation.proceed(); } else {// w ww . j a v a2 s . c o m //RowBounds-?Mybatis args[2] = RowBounds.DEFAULT; MappedStatement ms = (MappedStatement) args[0]; Object parameterObject = args[1]; BoundSql boundSql = ms.getBoundSql(parameterObject); //? Page page = localPage.get(); //?? localPage.remove(); if (page == null) { if (offsetAsPageNum) { page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount ? Page.SQL_COUNT : Page.NO_SQL_COUNT); } else { page = new Page(rowBounds, rowBoundsWithCount ? Page.SQL_COUNT : Page.NO_SQL_COUNT); } } MappedStatement qs = newMappedStatement(ms, new BoundSqlSqlSource(boundSql)); //?MappedStatement?qs? args[0] = qs; MetaObject msObject = SystemMetaObject.forObject(qs); String sql = (String) msObject.getValue("sqlSource.boundSql.sql"); //?total??count if (page.getTotal() > Page.NO_SQL_COUNT) { //count - ?sql msObject.setValue("sqlSource.boundSql.sql", getCountSql(sql)); // Object result = invocation.proceed(); int totalCount = (Integer) ((List) result).get(0); page.setTotal(totalCount); int totalPage = totalCount / page.getPageSize() + ((totalCount % page.getPageSize() == 0) ? 0 : 1); page.setPages(totalPage); //sql - ?sql msObject.setValue("sqlSource.boundSql.sql", getPageSql(sql, page)); //?? msObject.setValue("resultMaps", ms.getResultMaps()); // result = invocation.proceed(); //? page.addAll((List) result); // return page; } else { //sql - ?sql msObject.setValue("sqlSource.boundSql.sql", getPageSql(sql, page)); //?? msObject.setValue("resultMaps", ms.getResultMaps()); // Object result = invocation.proceed(); //? page.addAll((List) result); // return page; } } }
From source file:cn.org.awcp.core.mybatis.page.Page.java
License:Open Source License
public Page(RowBounds rowBounds, int total) { super(rowBounds.getLimit() > -1 ? rowBounds.getLimit() : 0); this.pageSize = rowBounds.getLimit(); this.startRow = rowBounds.getOffset(); //RowBounds??countcount,?SQL_COUNT this.total = total; this.endRow = this.startRow + this.pageSize; }
From source file:cn.org.awcp.core.mybatis.page.PageHelper.java
License:Open Source License
/** * ??//from w w w .j av a 2s . c o m * * @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); } } //?? page.setReasonable(reasonable); return page; }
From source file:com.appleframework.orm.mybatis.pagehelper.SqlUtil.java
License:Open Source License
/** * ??// w w w . j a va 2s. c o m * * @param args * @return Page */ public Page getPage(Object[] args) { Page page = getLocalPage(); if (page == null) { if (args[2] instanceof RowBounds && args[2] != RowBounds.DEFAULT) { RowBounds rowBounds = (RowBounds) args[2]; if (offsetAsPageNum) { page = new Page(rowBounds.getOffset(), rowBounds.getLimit(), rowBoundsWithCount); } else { page = new Page(new int[] { rowBounds.getOffset(), rowBounds.getLimit() }, rowBoundsWithCount); //offsetAsPageNum=falsePageNum?reasonablefalse page.setReasonable(false); } } else { try { page = getPageFromObject(args[1]); } catch (Exception e) { return null; } } setLocalPage(page); } //?? if (page.getReasonable() == null) { page.setReasonable(reasonable); } //truepagesize0RowBoundslimit=0? if (page.getPageSizeZero() == null) { page.setPageSizeZero(pageSizeZero); } return page; }
From source file:com.autonavi.tsp.workbackend.util.page.PageHelper.java
License:Open Source License
/** * ??/* ww w. ja v a 2 s . c o m*/ * * @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); } //truepagesize0RowBoundslimit=0? if (page.getPageSizeZero() == null) { page.setPageSizeZero(pageSizeZero); } return page; }
From source file:com.baomidou.mybatisplus.plugins.pagination.DialectFactory.java
License:Apache License
/** * Physical Pagination Interceptor for all the queries with parameter * {@link org.apache.ibatis.session.RowBounds} * * @param rowBounds//from w w w.j a v a 2s . c o m * @param buildSql * @param dialectType * @param dialectClazz * @return * @throws Exception */ public static String buildPaginationSql(RowBounds rowBounds, String buildSql, String dialectType, String dialectClazz) throws Exception { // fix #196 return getiDialect(dialectType, dialectClazz).buildPaginationSql(buildSql, rowBounds.getOffset(), rowBounds.getLimit()); }
From source file:com.cheyipai.platformservice.thirdparty.core.pager.PageHelper.java
License:Open Source License
/** * ??//from w w w. j a va 2 s . c om * * @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); } } return page; }
From source file:com.dao.genericdao.mybatis.plugins.page.support.PageHelper.java
License:Open Source License
public PageHelper(RowBounds rowBounds, int total) { super(rowBounds.getLimit() > -1 ? rowBounds.getLimit() : 0); this.pageSize = rowBounds.getLimit(); this.startRow = rowBounds.getOffset(); //RowBounds??countcount,?SQL_COUNT this.total = total; this.endRow = this.startRow + this.pageSize; }
From source file:com.dao.genericdao.mybatis.plugins.page.support.SqlUtil.java
License:Open Source License
/** * ??/*from w w w . ja v a 2s. co m*/ * * @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); } //truepagesize0RowBoundslimit=0? if (page.getPageSizeZero() == null) { page.setPageSizeZero(pageSizeZero); } return page; }