org.teiid.query.sql.lang.Query.setOrderBy()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(455)

本文整理了Java中org.teiid.query.sql.lang.Query.setOrderBy方法的一些代码示例,展示了Query.setOrderBy的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.setOrderBy方法的具体详情如下:
包路径:org.teiid.query.sql.lang.Query
类名称:Query
方法名:setOrderBy

Query.setOrderBy介绍

暂无

代码示例

代码示例来源:origin: org.jboss.teiid/teiid-engine

/**
 * Constructs an instance of this class given the specified clauses
 * @param select SELECT clause
 * @param from FROM clause
 * @param criteria WHERE clause
 * @param orderBy ORDER BY clause
 * @param option OPTION clause
 */
public Query( Select select, From from, Criteria criteria, OrderBy orderBy, Option option ) {
  super();
  setSelect( select );
  setFrom( from );
  setCriteria( criteria );
  setOrderBy( orderBy );
  setOption( option );
}

代码示例来源:origin: org.teiid/teiid-engine

/**
 * Constructs an instance of this class given the specified clauses
 * @param select SELECT clause
 * @param from FROM clause
 * @param criteria WHERE clause
 * @param orderBy ORDER BY clause
 * @param option OPTION clause
 */
public Query( Select select, From from, Criteria criteria, OrderBy orderBy, Option option ) {
  super();
  setSelect( select );
  setFrom( from );
  setCriteria( criteria );
  setOrderBy( orderBy );
  setOption( option );
}

代码示例来源:origin: teiid/teiid

/**
 * Constructs an instance of this class given the specified clauses
 * @param select SELECT clause
 * @param from FROM clause
 * @param criteria WHERE clause
 * @param orderBy ORDER BY clause
 * @param option OPTION clause
 */
public Query( Select select, From from, Criteria criteria, OrderBy orderBy, Option option ) {
  super();
  setSelect( select );
  setFrom( from );
  setCriteria( criteria );
  setOrderBy( orderBy );
  setOption( option );
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

private boolean canRaiseInputset(Command command, Collection<ElementSymbol> bindings) {
  // check to see if this is query.
  if (!(command instanceof Query)) {
    return false;
  }
  
  Query query = (Query)command; 
  Criteria crit = query.getCriteria();
  
  if (crit != null && (query.getGroupBy() != null || query.getHaving() != null || query.getLimit() != null)) {
    return false;
  }
  //temporarily remove the criteria
  query.setCriteria(null);
  //just throw away order by
  query.setOrderBy(null);
  
  List<ElementSymbol> references = QueryUtil.getBindingsReferences(query, bindings);
  query.setCriteria(crit);
  
  //if there are any input set bindings in the rest of the command, don't convert
  return references.isEmpty();
}

代码示例来源:origin: org.teiid/teiid-olingo

public Query selectQuery() throws TeiidException {
  
  if (!this.exceptions.isEmpty()) {
    throw this.exceptions.get(0);
  }
  Query query = this.context.buildQuery();
  if (this.countQuery) {
    AggregateSymbol aggregateSymbol = new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null);
    Select select = new Select(Arrays.asList(aggregateSymbol));
    query.setSelect(select);
  } else if (this.orderBy != null) {
    if (this.context.getIterator() != null) {
      //currently this doesn't matter as the ordering can only be based upon the parent entity
      ((AggregateSymbol)((AliasSymbol)query.getSelect().getSymbol(query.getSelect().getProjectedSymbols().size() - 1)).getSymbol()).setOrderBy(this.orderBy);
    } else {
      query.setOrderBy(this.orderBy);
    }
  }
  
  if (this.expandOption != null) {
    processExpandOption(this.expandOption, this.context, query, 1, null);
  }
  
  return query;
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

/**
 * Constructs an instance of this class given all the clauses
 * @param select SELECT clause
 * @param from FROM clause
 * @param criteria WHERE clause
 * @param groupBy GROUP BY clause
 * @param having HAVING clause
 * @param orderBy ORDER BY clause
 * @param option OPTION clause
 */
public Query( Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option ) {
  super();
  setSelect( select );
  setFrom( from );
  setCriteria( criteria );
  setGroupBy( groupBy );
  setHaving( having );
  setOrderBy( orderBy );
  setOption( option );
}

代码示例来源:origin: org.teiid/teiid-engine

/**
 * Constructs an instance of this class given all the clauses
 * @param select SELECT clause
 * @param from FROM clause
 * @param criteria WHERE clause
 * @param groupBy GROUP BY clause
 * @param having HAVING clause
 * @param orderBy ORDER BY clause
 * @param option OPTION clause
 */
public Query( Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option ) {
  super();
  setSelect( select );
  setFrom( from );
  setCriteria( criteria );
  setGroupBy( groupBy );
  setHaving( having );
  setOrderBy( orderBy );
  setOption( option );
}

代码示例来源:origin: teiid/teiid

/**
 * Constructs an instance of this class given all the clauses
 * @param select SELECT clause
 * @param from FROM clause
 * @param criteria WHERE clause
 * @param groupBy GROUP BY clause
 * @param having HAVING clause
 * @param orderBy ORDER BY clause
 * @param option OPTION clause
 */
public Query( Select select, From from, Criteria criteria, GroupBy groupBy, Criteria having, OrderBy orderBy, Option option ) {
  super();
  setSelect( select );
  setFrom( from );
  setCriteria( criteria );
  setGroupBy( groupBy );
  setHaving( having );
  setOrderBy( orderBy );
  setOption( option );
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

query.setOrderBy(null);

代码示例来源:origin: teiid/teiid

@Test public void testQuery4() {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  From from = new From();
  from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
  CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
  CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
  OrderBy orderBy = new OrderBy();
  orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
  
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setCriteria(cc);
  query.setHaving(having);
  query.setOrderBy(orderBy);
  
  helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 HAVING e1 > 0 ORDER BY e1");		     //$NON-NLS-1$
}

代码示例来源:origin: org.jboss.teiid/teiid-engine

static void planQueries(final MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv) 
  throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
  ResultSetInfo rsInfo = sourceNode.getResultSetInfo();
  
  // Create sql:  SELECT * FROM rsName            
  Query rsQuery = (Query)rsInfo.getCommand();
  
  // add user order by to base query
  rsQuery.setOrderBy(rsInfo.getOrderBy());
  // add user criteria to base query from model
  Criteria crit = rsInfo.getCriteria();
  try {
    if(crit != null) {
      planQueryWithCriteria(sourceNode, planEnv);
    }
  } catch (QueryResolverException e) {
     throw new TeiidComponentException(QueryPlugin.Event.TEIID30294, e);
  }
  if (rsInfo.getUserRowLimit() != -1) {
    int limit = rsInfo.getUserRowLimit();
    if (rsInfo.exceptionOnRowlimit()) {
      limit++;
    }
    rsQuery.setLimit(new Limit(null, new Constant(limit)));
  }
  
  // this query is not eligible for staging; proceed normally.
  rsInfo.setCommand(rsQuery);            
}

代码示例来源:origin: teiid/teiid

@Test public void testQuery2() {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  From from = new From();
  from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
  CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
  GroupBy groupBy = new GroupBy();
  groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
  OrderBy orderBy = new OrderBy();
  orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
  
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setCriteria(cc);
  query.setGroupBy(groupBy);
  query.setHaving(having);
  query.setOrderBy(orderBy);
  
  helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 HAVING e1 > 0 ORDER BY e1");		     //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testQuery7() {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  From from = new From();
  from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
  CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
  GroupBy groupBy = new GroupBy();
  groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
  OrderBy orderBy = new OrderBy();
  orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
  
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setCriteria(cc);
  query.setGroupBy(groupBy);
  query.setHaving(having);
  query.setOrderBy(orderBy);
  
  helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 HAVING e1 > 0 ORDER BY e1");		     //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testQuery3() {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  From from = new From();
  from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
  GroupBy groupBy = new GroupBy();
  groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  CompareCriteria having = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.GT, new Constant(new Integer(0))); //$NON-NLS-1$
  OrderBy orderBy = new OrderBy();
  orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
  
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setGroupBy(groupBy);
  query.setHaving(having);
  query.setOrderBy(orderBy);
  
  helpTest(query, "SELECT * FROM m.g GROUP BY e1 HAVING e1 > 0 ORDER BY e1");		     //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

@Test public void testQuery5() {
  Select select = new Select();
  select.addSymbol(new MultipleElementSymbol());
  From from = new From();
  from.addGroup(new GroupSymbol("m.g")); //$NON-NLS-1$
  CompareCriteria cc = new CompareCriteria(new ElementSymbol("e1"), CompareCriteria.EQ, new Constant(new Integer(5))); //$NON-NLS-1$
  GroupBy groupBy = new GroupBy();
  groupBy.addSymbol(new ElementSymbol("e1")); //$NON-NLS-1$
  OrderBy orderBy = new OrderBy();
  orderBy.addVariable(new ElementSymbol("e1")); //$NON-NLS-1$
  
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setCriteria(cc);
  query.setGroupBy(groupBy);
  query.setOrderBy(orderBy);
  
  helpTest(query, "SELECT * FROM m.g WHERE e1 = 5 GROUP BY e1 ORDER BY e1");		     //$NON-NLS-1$
}

代码示例来源:origin: teiid/teiid

/** SELECT y FROM h ORDER BY x */
public static final Query sample1() { 
  Query q2 = new Query();
  Select select = new Select();
  select.addSymbol(new ElementSymbol("y"));        //$NON-NLS-1$
  q2.setSelect(select);        
  From from = new From();
  from.addGroup(new GroupSymbol("h")); //$NON-NLS-1$
  q2.setFrom(from);
  OrderBy orderBy = new OrderBy();
  orderBy.addVariable(new ElementSymbol("x")); //$NON-NLS-1$
  q2.setOrderBy(orderBy); 
  return q2;    
}

代码示例来源:origin: teiid/teiid

@Test public void testOrderByWithNumbers_AsInt() throws Exception {
  GroupSymbol g = new GroupSymbol("z"); //$NON-NLS-1$
  From from = new From();
  from.addGroup(g);
  
  Select select = new Select();
  select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$
  select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
  OrderBy orderby = new OrderBy();
  orderby.addVariable(new Constant(1), true); //$NON-NLS-1$
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setOrderBy(orderby);        
      
  helpTest("SELECT x, y FROM z order by 1", "SELECT x, y FROM z ORDER BY 1", query); //$NON-NLS-1$ //$NON-NLS-2$        
}

代码示例来源:origin: teiid/teiid

@Test public void testOrderByWithNumbers_InQuotes() throws Exception {       
  GroupSymbol g = new GroupSymbol("z"); //$NON-NLS-1$
  From from = new From();
  from.addGroup(g);
  
  Select select = new Select();
  select.addSymbol(new ElementSymbol("x")); //$NON-NLS-1$
  select.addSymbol(new ElementSymbol("y")); //$NON-NLS-1$
  OrderBy orderby = new OrderBy();
  orderby.addVariable(new ElementSymbol("1"), true); //$NON-NLS-1$
  Query query = new Query();
  query.setSelect(select);
  query.setFrom(from);
  query.setOrderBy(orderby);
  
  helpTest("SELECT x, y from z order by \"1\"", "SELECT x, y FROM z ORDER BY \"1\"", query); //$NON-NLS-1$ //$NON-NLS-2$
}

代码示例来源:origin: teiid/teiid

query.setSelect(select);
query.setFrom(from);
query.setOrderBy(orderBy);

代码示例来源:origin: teiid/teiid

query.setOrderBy(null);
SymbolMap expressionMapping = SymbolMap.createSymbolMap(delete.getGroup(), query.getProjectedSymbols(), metadata);

相关文章