Package org.teiid.query.sql.lang

Examples of org.teiid.query.sql.lang.Limit


        return evaluateCriteria(criteria);
  }

  private void addImplicitLimit(SubqueryContainer<QueryCommand> container, int rowLimit) {
    if (container.getCommand().getLimit() != null) {
      Limit lim = container.getCommand().getLimit();
      if (lim.getRowLimit() instanceof Constant) {
        Constant c = (Constant)lim.getRowLimit();
        if (!c.isMultiValued() && Integer.valueOf(rowLimit).compareTo((Integer) c.getValue()) <= 0) {
          lim.setRowLimit(new Constant(rowLimit));
          if (lim.getRowLimit() == null) {
            lim.setImplicit(true);
            container.getCommand().setOrderBy(null);
          }
        }
      }
      return;
    }
    boolean addLimit = true;
    if (container.getCommand() instanceof Query) {
      Query query = (Query)container.getCommand();
      addLimit = !(query.hasAggregates() && query.getGroupBy() == null);
    }
    if (addLimit) {
      Limit lim = new Limit(null, new Constant(rowLimit));
      lim.setImplicit(true);
      container.getCommand().setLimit(lim);
    }
  }
View Full Code Here


        switch(cmdType) {
            case Command.TYPE_QUERY:
               
                QueryCommand queryCommand = (QueryCommand) command;
               
                Limit limit = queryCommand.getLimit();
               
                if (limit != null && limit.getRowLimit() instanceof Constant) {
                    Constant rowLimit = (Constant)limit.getRowLimit();
                    if (Integer.valueOf(0).equals(rowLimit.getValue())) {
                        return false;
                    }
                }
           
View Full Code Here

        Query query = new Query();
        Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
        From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
        query.setSelect(select);
        query.setFrom(from);
        query.setLimit(new Limit(null, new Constant(new Integer(100))));
        helpTest(query, "SELECT * FROM a LIMIT 100"); //$NON-NLS-1$
    }
View Full Code Here

        Query query = new Query();
        Select select = new Select(Arrays.asList(new Object[] {new AllSymbol()}));
        From from = new From(Arrays.asList(new UnaryFromClause(new GroupSymbol("a")))); //$NON-NLS-1$
        query.setSelect(select);
        query.setFrom(from);
        query.setLimit(new Limit(new Constant(new Integer(50)), new Constant(new Integer(100))));
        helpTest(query, "SELECT * FROM a LIMIT 50, 100"); //$NON-NLS-1$
    }
View Full Code Here

         * doesn't already have a limit clause.
         */
        if (requestMsg.getRowLimit() > 0 && command instanceof QueryCommand) {
            QueryCommand query = (QueryCommand)command;
            if (query.getLimit() == null) {
                query.setLimit(new Limit(null, new Constant(new Integer(requestMsg.getRowLimit()), DataTypeManager.DefaultDataClasses.INTEGER)));
                this.addedLimit = true;
            }
        }
       
        try {
View Full Code Here

TOP

Related Classes of org.teiid.query.sql.lang.Limit

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.