Example usage for org.apache.ibatis.session RowBounds NO_ROW_LIMIT

List of usage examples for org.apache.ibatis.session RowBounds NO_ROW_LIMIT

Introduction

In this page you can find the example usage for org.apache.ibatis.session RowBounds NO_ROW_LIMIT.

Prototype

int NO_ROW_LIMIT

To view the source code for org.apache.ibatis.session RowBounds NO_ROW_LIMIT.

Click Source Link

Usage

From source file:org.alfresco.repo.domain.activities.ibatis.ActivityPostDAOImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
public List<ActivityPostEntity> selectPosts(ActivityPostEntity activityPost, int maxItems) throws SQLException {
    int rowLimit = maxItems < 0 ? RowBounds.NO_ROW_LIMIT : maxItems;
    RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, rowLimit);

    if ((activityPost.getJobTaskNode() != -1) && (activityPost.getMinId() != -1)
            && (activityPost.getMaxId() != -1) && (activityPost.getStatus() != null)) {
        return template.selectList("alfresco.activities.select_activity_posts_by_params", activityPost,
                rowBounds);//w ww.  j a  va 2  s.c o  m
    } else if (activityPost.getStatus() != null) {
        return template.selectList("alfresco.activities.select_activity_posts_by_status", activityPost,
                rowBounds);
    } else {
        return new ArrayList<ActivityPostEntity>(0);
    }
}

From source file:org.alfresco.repo.domain.permissions.ibatis.AclCrudDAOImpl.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from  w w w  .  j  av  a2s.co  m*/
protected List<Long> getADMNodeEntityIdsByAcl(long aclEntityId, int maxResults) {
    if (maxResults < 0) {
        maxResults = RowBounds.NO_ROW_LIMIT;
    }

    Map<String, Object> params = new HashMap<String, Object>(1);
    params.put("id", aclEntityId);

    return template.selectList(SELECT_ADM_NODES_BY_ACL, params, new RowBounds(0, maxResults));
}

From source file:org.apache.playframework.mybatisplus.plugins.PaginationInterceptor.java

License:Apache License

public Object intercept(Invocation invocation) throws Throwable {

    Object target = invocation.getTarget();
    if (target instanceof StatementHandler) {
        StatementHandler statementHandler = (StatementHandler) target;
        MetaObject metaStatementHandler = SystemMetaObject.forObject(statementHandler);
        RowBounds rowBounds = (RowBounds) metaStatementHandler.getValue("delegate.rowBounds");
        Configuration configuration = (Configuration) metaStatementHandler.getValue("delegate.configuration");
        BoundSql boundSql = (BoundSql) metaStatementHandler.getValue("delegate.boundSql");
        String originalSql = (String) boundSql.getSql();
        /* ?? *///from w ww.ja  va 2s  . c om
        if (rowBounds != null && rowBounds != RowBounds.DEFAULT) {

            /* ? */
            IDialect dialect = getiDialect();

            /*
             * <p> ? </p> <p> ???????
             * </p>
             */
            metaStatementHandler.setValue("delegate.rowBounds.offset", RowBounds.NO_ROW_OFFSET);
            metaStatementHandler.setValue("delegate.rowBounds.limit", RowBounds.NO_ROW_LIMIT);

            /**
             * <p>
             * 
             * </p>
             * <p>
             *  count
             * </p>
             */
            if (rowBounds instanceof Pagination) {
                Pagination page = (Pagination) rowBounds;
                boolean orderBy = true;
                if (page.isSearchCount()) {
                    /*
                     * COUNT  ORDER BY  SQL
                     */
                    CountOptimize countOptimize = SqlUtils.getCountOptimize(originalSql, optimizeType,
                            dialectType, page.isOptimizeCount());
                    orderBy = countOptimize.isOrderBy();
                }
                /*  SQL */
                String buildSql = SqlUtils.concatOrderBy(originalSql, page, orderBy);
                originalSql = dialect.buildPaginationSql(buildSql, page.getOffsetCurrent(), page.getSize());
            }
        }
        /**
         *  SQL 
         */
        metaStatementHandler.setValue("delegate.boundSql.sql", buildSql(originalSql, configuration));
    } else {
        MappedStatement mappedStatement = (MappedStatement) invocation.getArgs()[0];
        Object parameterObject = null;
        RowBounds rowBounds = null;
        if (invocation.getArgs().length > 1) {
            parameterObject = invocation.getArgs()[1];
            rowBounds = (RowBounds) invocation.getArgs()[2];
        }
        /* ??? */
        if (rowBounds == null || rowBounds == RowBounds.DEFAULT) {
            return invocation.proceed();
        }

        BoundSql boundSql = mappedStatement.getBoundSql(parameterObject);
        /*
         * <p> ? </p> <p> ???????
         * </p>
         */
        String originalSql = (String) boundSql.getSql();

        /**
         * <p>
         * 
         * </p>
         * <p>
         *  count
         * </p>
         */
        if (rowBounds instanceof Pagination) {
            Connection connection = null;
            try {
                connection = mappedStatement.getConfiguration().getEnvironment().getDataSource()
                        .getConnection();
                Pagination page = (Pagination) rowBounds;
                if (page.isSearchCount()) {
                    /*
                     * COUNT  ORDER BY  SQL
                     */
                    CountOptimize countOptimize = SqlUtils.getCountOptimize(originalSql, optimizeType,
                            dialectType, page.isOptimizeCount());
                    page = this.count(countOptimize.getCountSQL(), connection, mappedStatement, boundSql, page);
                    /**  0  */
                    if (page.getTotal() <= 0) {
                        return invocation.proceed();
                    }
                }
            } finally {
                IOUtils.closeQuietly(connection);
            }
        }
    }

    return invocation.proceed();

}

From source file:org.nebula.service.dao.PaginationInterceptor.java

License:Apache License

public Object intercept(Invocation inv) throws Throwable {

    StatementHandler target = (StatementHandler) inv.getTarget();
    BoundSql boundSql = target.getBoundSql();
    String sql = boundSql.getSql();
    if (StringUtils.isBlank(sql)) {
        return inv.proceed();
    }//from   w w w  . j  a va2  s .  co m
    logger.debug("origin sql>>>>>" + sql.replaceAll("\n", ""));
    // ?select??
    if (sql.matches(SQL_SELECT_REGEX) && !Pattern.matches(SQL_COUNT_REGEX, sql)) {
        Object obj = FieldUtils.readField(target, "delegate", true);
        // ??? RowBounds 
        RowBounds rowBounds = (RowBounds) FieldUtils.readField(obj, "rowBounds", true);
        // ??SQL
        if (rowBounds != null && rowBounds != RowBounds.DEFAULT) {
            FieldUtils.writeField(boundSql, "sql", newSql(sql, rowBounds), true);
            logger.debug("new sql>>>>>" + boundSql.getSql().replaceAll("\n", ""));
            // ???(?)
            FieldUtils.writeField(rowBounds, "offset", RowBounds.NO_ROW_OFFSET, true);
            FieldUtils.writeField(rowBounds, "limit", RowBounds.NO_ROW_LIMIT, true);
        }
    }
    return inv.proceed();
}

From source file:org.openlmis.lookupapi.controller.LookupController.java

License:Open Source License

@ApiOperation(value = "Products", notes = "Returns a list of products.", response = Product.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful request", response = Product.class),
        @ApiResponse(code = 500, message = "Internal server error") })
@RequestMapping(value = "/rest-api/lookup/products", method = RequestMethod.GET, headers = ACCEPT_JSON)
public ResponseEntity getProducts(@RequestParam(value = "page", defaultValue = "1") Integer page,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(value = "paging", defaultValue = "true") Boolean paging) {
    RowBounds rowBounds = paging ? new RowBounds(page, pageSize)
            : new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
    return RestResponse.response(PRODUCTS, lookupService.getFullProductList(rowBounds));
}

From source file:org.openlmis.lookupapi.controller.LookupController.java

License:Open Source License

@ApiOperation(value = "Facilities", notes = "Returns a list of facilities.", response = Facility.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Successful request", response = Facility.class),
        @ApiResponse(code = 500, message = "Internal server error") })
@RequestMapping(value = "/rest-api/lookup/facilities", method = RequestMethod.GET, headers = ACCEPT_JSON)
public ResponseEntity getFacilities(@RequestParam(value = "page", defaultValue = "1") Integer page,
        @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
        @RequestParam(value = "paging", defaultValue = "true") Boolean paging) {
    RowBounds rowBounds = paging ? new RowBounds(page, pageSize)
            : new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
    return RestResponse.response(FACILITIES, lookupService.getAllFacilities(rowBounds));
}

From source file:org.openlmis.report.controller.ReportLookupController.java

License:Open Source License

@RequestMapping(value = "/allFacilities", method = GET, headers = BaseController.ACCEPT_JSON)
public ResponseEntity<OpenLmisResponse> getAllFacilities() {
    return OpenLmisResponse.response(ALL_FACILITIES, reportLookupService
            .getAllFacilities(new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT)));
}

From source file:org.openlmis.report.service.AdjustmentSummaryReportDataProvider.java

License:Open Source License

@Override
protected List<? extends ReportData> getResultSet(Map<String, String[]> filterCriteria) {
    return getReportBody(filterCriteria, null, RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
}

From source file:org.openlmis.report.service.AggregateRegimenSummaryReportDataProvider.java

License:Open Source License

@Override
protected List<? extends ReportData> getResultSet(Map<String, String[]> filterCriteria) {
    RowBounds rowBounds = new RowBounds(RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
    return reportMapper.getAggregateReport(getReportFilterData(filterCriteria), null, rowBounds,
            this.getUserId());
}

From source file:org.openlmis.report.service.AverageConsumptionReportDataProvider.java

License:Mozilla Public License

@Override
protected List<? extends ReportData> getResultSetReportData(Map<String, String[]> filterCriteria) {
    return getMainReportData(filterCriteria, null, RowBounds.NO_ROW_OFFSET, RowBounds.NO_ROW_LIMIT);
}